We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在monorepo仓库(lerna + yarn + typescript)中运行jest,结果报错Cannot find module 'X' from 'Y' 没想到是因为模块X中的package.json中没有main字段(jest对es6支持不好
Cannot find module 'X' from 'Y'
建议先检查跟moduleNameMapper有没有关系kulshekhar/ts-jest#269 如果不相关,请检查被依赖的module X中的package.json中没有main字段
解决方法:
moduleNameMapper
main
moduleNameMapper: { '^@your_scope/module_a': '<rootDir>/../module_a/src/index.ts', '^@your_scope/module_b': '<rootDir>/../module_b/src/b.ts' },
tsc -p . --target es5 --outDir dist/es5 && tsc -p . --target es6 --outDir dist/es6
在module X的package.json新增main字段
"main": "dist/es5/x.js", "module": "dist/es6/x.js",
SyntaxError:
The text was updated successfully, but these errors were encountered:
666,感谢,得救了
Sorry, something went wrong.
No branches or pull requests
在monorepo仓库(lerna + yarn + typescript)中运行jest,结果报错
Cannot find module 'X' from 'Y'
没想到是因为模块X中的package.json中没有main字段(jest对es6支持不好
建议先检查跟moduleNameMapper有没有关系kulshekhar/ts-jest#269
如果不相关,请检查被依赖的module X中的package.json中没有main字段
解决方法:
moduleNameMapper
映射,这样即使没有main
字段,也可以正确解析:tsc -p . --target es5 --outDir dist/es5 && tsc -p . --target es6 --outDir dist/es6
在module X的package.json新增main字段
Support the "module" package.json field jestjs/jest#2702
https://github.com/makotoshimazu/jest-module-field-resolver/blob/master/src/index.js
如果依赖是ES6语法,jest不会编译,会报错
SyntaxError:
The text was updated successfully, but these errors were encountered: