赞
踩
在开始接触到react之初,安装babel插件是一件必须要做的事情,但是我在安装的时候,出现了一个错误,这个错误刚开始很头疼,在网上找了各种解决的办法,但是一直不行,直到今天,也就是解决安装错误的第三天,临近崩溃的我,安装成功了,首先来看下错误。
ERROR in ./src/index.js
Module build failed (from ./node_modules/_babel-loader@8.0.5@babel-loader/lib/index.js):
Error: Cannot find module '@babel/core'
babel-loader@8 requires Babel 7.x (the package '@babel/core'). If you'd like to use Babel 6.x ('babel-core'), you should install 'babel-loader@7'.
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (D:\project\React\1react-webpack\node_modules\_babel-loader@8.0.5@babel-loader\lib\index.js:10:11)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
解决办法,加上
cnpm i babel-loader@7 -D
然后按照正常步骤安装。
我的安装步骤详见https://blog.csdn.net/zhuhui2000
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。