简体   繁体   中英

create-react-app always throws babel error

Every time I create a create-react-app project it throws this error:

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

  "babel-loader": "8.0.4"

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:

  /Users/dalegrant/Desktop/hyberchat-dashboard/client/node_modules/babel-loader (version: 8.0.5)

I have tried downgrading to 8.0.4,

I've tried installing 8.0.5

I've even made sure all my dependencies for babel rely on a 8.0.5!

I have no idea what to do from here as the error persists for every create react app I now build!

This must be a common problem, does anybody have an idea on how to get around this?!

在您的机器用户文件夹中,有一个node_modules目录和package-lock.json使用rm -rf User/node_modulesrm -rf User/package-lock.json删除node_module ,然后删除您的node_module目录和pack-lock.json文件项目再次运行npm install然后它就可以工作了

Remove the babel-loader package (also globally):

  npm uninstall babel-loader
  npm uninstall babel-loader -g

Then run create-react-app again, it should install the correct dependency.

If you use the babel-loader somewhere else, pin the dependency there to ensure this problem does not happen again.

you probably installed node_modules in your main folders before. Search for them and remove. In my case i have installed node_modules on my Home folder. When i removed files from this directory problem disapeared

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM