美文网首页让前端飞
babel-loader版本不一致报错

babel-loader版本不一致报错

作者: 废柴码农 | 来源:发表于2019-02-13 16:17 被阅读3次

在做项目的时候出现一个问题,由于babel-loader版本号不一致报错,报错如下图:

图中说:用create-react-app创建项目的时候所用到的babel-loader依赖是8.04版本,但是在我创建项目的node_modules下的babel-loader版本是8.0.5版本的.
npm报错.png

结果打开pakage.json和package-lock.json文件果然babel-loader版本不一样


json.png lock.png
解决办法其实第一张图已经给出1-7点
  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-loader" 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 /Users/amy/Projects/HandheldWestLake/node_modules/babel-loader is outside your project directory.
    For example, you might have accidentally installed something in your home folder.
  7. Try running npm ls babel-loader in your project folder.
    This will tell you which other package (apart from the expected react-scripts) installed babel-loader.
但是结合自己的文件整理出来了如下几个步骤:
1.删除package-lock.json文件
2.删除你文件夹中的node_modules模块
3.卸载package.json文件中的babel-loader 即npm uninstall babel-loader
4.安装你用到的版本 npm install babel-loader@8.04我的需要的是8.04
5.npm start启动项目

相关文章

网友评论

    本文标题:babel-loader版本不一致报错

    本文链接:https://www.haomeiwen.com/subject/gxrdeqtx.html