create-react-app,npm start 失败,babel-jest版本不一致的问题

问题

The react-scripts package provided by Create React App requires a dependency:

  "babel-jest": "23.6.0"

Don't try to install it manually: your package manager does it automatically.

However, a different version of babel-jest was detected higher up in the tree:

  /home/karan/workspace/node_modules/babel-jest (version: 22.4.4)

解决方法

1. 删除yarn.lock和node-modules

2. 修改package.json,添加

"resolutions": {

    "jest": "23.6.0",

    "babel-jest": "23.6.0"

},

3. npm install

4. npm start

可参考 https://yarnpkg.com/lang/en/docs/selective-version-resolutions/

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容