微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

反应:纱线开始错误

如何解决反应:纱线开始错误

$ yarn start
yarn run v1.22.5
$ react-scripts start

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App,but something you need to fix locally.

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

  "babel-jest": "^26.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:

  C:\Users\UNION\node_modules\babel-jest (version: 27.0.2)

Manually installing incompatible versions is kNown to cause hard-to-debug issues.

If you would prefer to ignore this check,add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree,try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-jest" from dependencies and/or devDependencies in 
the package.json file in your project folder.
  4. Run npm install or yarn,depending on the package manager you use.

In most cases,this should be enough to fix the problem.
If this has not helped,there are a few other things you can try:    

  5. If you used npm,install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has kNown issues with package hoisting which may get resolved in future versions.

  6. Check if C:\Users\UNION\node_modules\babel-jest is outside your 
project directory.
     For example,you might have accidentally installed something in 
your home folder.

  7. Try running npm ls babel-jest in your project folder.
     This will tell you which other package (apart from the expected 
react-scripts) installed babel-jest.

If nothing else helps,add SKIP_PREFLIGHT_CHECK=true to an .env file 
in your project.
That would permanently disable this preflight check in case you want 
to proceed anyway.

P.S. We kNow this message is long but please read the steps above :-) We hope you find them helpful!

error Command Failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. 
  • 我无法解决这个问题,我确实尝试了以下步骤,但似乎我没有得到这个?请给一些建议,以便我可以顺利地完成我的项目。
  • 每当我倾向于运行 yarn start 时,它都会向我显示错误

解决方法

您的用户配置文件目录中有一个不应该存在的 node_modules 文件夹。也许您在没有 npm install <something> 的情况下偶然在用户个人资料中运行了 -g

删除 c:\Users\UNION\node_modules 就可以了。


请注意,这实际上在您已经获得的建议列表中:

  6. Check if C:\Users\UNION\node_modules\babel-jest is outside your  project directory.
     For example,you might have accidentally installed something in  your home folder.

您写道,您尝试了这些步骤 - 下次如果您还可以在问题中包含这些尝试的结果,那么我们就知道您尝试了什么以及它产生了什么效果,那就太好了。在这种情况下,例如“#6:是的,它在我的项目目录之外,但我不知道该怎么做”。

,

答案就在问题中!

To fix the dependency tree,try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-jest" from dependencies and/or devDependencies in  the package.json file in your project folder.
  4. Run npm install or yarn,depending on the package manager you use.

In most cases,this should be enough to fix the problem. If this has not helped,there are a few other things you can try:    

  5. If you used npm,install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if C:\Users\UNION\node_modules\babel-jest is outside your  project directory.
     For example,you might have accidentally installed something in  your home folder.

  7. Try running npm ls babel-jest in your project folder.
     This will tell you which other package (apart from the expected  react-scripts) installed babel-jest.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。