Create React App requires a dependency: “babel-loader”: “8.1.0”

时光毁灭记忆、已成空白 提交于 2020-07-23 06:31:31

问题


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 locall y.

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

"babel-loader": "8.1.0"

Don't try to install it manually: your package manager does it automatically. However, a different version of babel-loader was detected higher up in the tree:

D:\Reactjs\node_modules\babel-loader (version: 8.0.6)

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 .e nv 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 proje ct folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-loader" from dependencies and/or devDependencies in the packa ge.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:

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

  2. Check if D:\Reactjs\node_modules\babel-loader is outside your project direc tory. For example, you might have accidentally installed something in your home f older.

  3. Try running npm ls babel-loader in your project folder. This will tell you which other package (apart from the expected react-scrip ts) installed babel-loader.

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


回答1:


Please if you haven't already, try the troubleshooting guide. If that fails too create a .env file in your root directory add SKIP_PREFLIGHT_CHECK=true and relaunch with npm start. If that doesn't help either just use yarn instead. It should work. For most people deleting the node_modules folder and reinstalling solves the issue.

npm i yarn -g




回答2:


In your machine user folder there is a node_modules directory and package-lock.json remove them using rm -rf User/node_modules and rm -rf User/package-lock.json after that delete node_module directory and pack-lock.json file in your project run npm install again then it's works



来源:https://stackoverflow.com/questions/60964631/create-react-app-requires-a-dependency-babel-loader-8-1-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!