wabpack 配置babel报错问题解决
程序员文章站
2024-03-26 12:20:11
...
当我们运行 npn run dev 时babel报错,这是因为babel-loader和babel对应的版本需要一致。
ERROR in ./src/js/index.js
Module build failed (from ./node_modules/_babel-[email protected]8.1.0@babel-loader/lib/index.js):
Error: Cannot find module '@babel/core'
Require stack:
- E:\web\webpack\04study\01study\node_modules\_babel-[email protected]8.1.0@babel-loader\lib\index.js
- E:\web\webpack\04study\01study\node_modules\_loader-[email protected]2.4.0@loader-runner\lib\loadLoader.js
- E:\web\webpack\04study\01study\node_modules\_loader-[email protected]2.4.0@loader-runner\lib\LoaderRunner.js
- E:\web\webpack\04study\01study\node_modules\[email protected]4.43.0@webpack\lib\NormalModule.js
- E:\web\webpack\04study\01study\node_modules\[email protected]4.43.0@webpack\lib\NormalModuleFactory.js- E:\web\webpack\04study\01study\node_modules\[email protected]4.43.0@webpack\lib\Compiler.js
- E:\web\webpack\04study\01study\node_modules\[email protected]4.43.0@webpack\lib\webpack.js
- E:\web\webpack\04study\01study\node_modules\_webpack-dev-[email protected]3.11.0@webpack-dev-server\bin\webpack-dev-server.js
babel-[email protected]8 requires Babel 7.x (the package '@babel/core'). If you'd like to use Babel 6.x ('babel-core'), you should install 'babel-[email protected]7'.
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (E:\web\webpack\04study\01study\node_modules\_babel-[email protected]8.1.0@babel-loader\lib\index.js:10:11)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
既然版本要一直,那么我们对应的解决办法就会有两种让两者版本一致:
1、降低babel-loader版本:
npm i babel-core babel-[email protected]7 babel-preset-env -D
2、升级babel到最新版本版本
npm i @babel/core babel-loader @babel/preset-env -D
上一篇: 【Spring MVC】中文乱码问题解决
下一篇: 问题:Git仓库中的.gitignore文件失效 博客分类: ··············未分类············· gitignore
推荐阅读
-
wabpack 配置babel报错问题解决
-
android studio 3.0.1依赖butterknife报错问题解决办法以及androidstudio2.0和3.0以上butterknife的配置大全
-
使用for of循环遍历获取的nodeList,配置babel编译,webpack打包之后在iphone5下报错
-
【Laravel5.5 笔记整理一】用 虚拟域名访问 报错问题解决及虚拟域名的配置
-
使用for of循环遍历获取的nodeList,配置babel编译,webpack打包之后在iphone5下报错
-
eslint配置import/no-extraneous-dependencies 引入内置模块path报错问题解决