每当我运行该程序时,都会出现此错误:
ERROR in ./index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.
at throwVersionError (E:\ReactJS final\node_modules\@babel\helper-plugin-utils\lib\index.js:65:11)
at Object.assertVersion (E:\ReactJS final\node_modules\@babel\helper-plugin-utils\lib\index.js:13:11)
at _default (E:\ReactJS final\node_modules\@babel\plugin-proposal-object-rest-spread\lib\index.js:51:7)
at E:\ReactJS final\node_modules\@babel\helper-plugin-utils\lib\index.js:19:12
at Function.memoisePluginContainer (E:\ReactJS final\node_modules\babel-core\lib\transformation\file\options\option-manager.js:113:13)
at Function.normalisePlugin (E:\ReactJS final\node_modules\babel-core\lib\transformation\file\options\option-manager.js:146:32)
at E:\ReactJS final\node_modules\babel-core\lib\transformation\file\options\option-manager.js:184:30
at Array.map (<anonymous>)
at Function.normalisePlugins (E:\ReactJS final\node_modules\babel-core\lib\transformation\file\options\option-manager.js:158:20)
at OptionManager.mergeOptions (E:\ReactJS final\node_modules\babel-core\lib\transformation\file\options\option-manager.js:234:36)
at OptionManager.init (E:\ReactJS final\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
at File.initOptions (E:\ReactJS final\node_modules\babel-core\lib\transformation\file\index.js:212:65)
at new File (E:\ReactJS final\node_modules\babel-core\lib\transformation\file\index.js:135:24)
at Pipeline.transform (E:\ReactJS final\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
at transpile (E:\ReactJS final\node_modules\babel-loader\lib\index.js:50:20)
at Object.module.exports (E:\ReactJS final\node_modules\babel-loader\lib\index.js:173:20)
i 「wdm」: Failed to compile.
请帮助我解决此问题。 (我还在这里附加了package.json文件)
{
"name": "reactjs-final",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"it": "webpack-dev-server --hot"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/plugin-proposal-object-rest-spread": "^7.5.1",
"@babel/preset-env": "^7.5.4",
"babel-loader": "^7.1.5",
"babel-preset-stage-0": "^6.24.1",
"babel-preset-stage-3": "^6.24.1",
"webpack": "^4.33.0",
"webpack-cli": "^3.3.3",
"webpack-dev-server": "^3.7.0"
},
"dependencies": {
"@babel/cli": "^7.5.0",
"@babel/core": "^7.5.4",
"@deck.gl/core": "^7.0.0",
"@deck.gl/mapbox": "^7.1.4",
"@fortawesome/fontawesome-free": "^5.9.0",
"@mapbox/mapbox-gl-geocoder": "^4.4.0",
"@mapbox/mapbox-sdk": "^0.6.0",
"@mapbox/react-geocoder": "^2.5.0",
"axios": "^0.19.0",
"babel-core": "^6.26.3",
"babel-install": "^2.1.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"debounce": "^1.2.0",
"deck.gl": "^7.1.4",
"dotenv": "^8.0.0",
"formik": "^1.5.7",
"http-proxy-middleware": "^0.19.1",
"install-peers": "^1.0.3",
"mapbox-gl": "^0.47.0",
"npm-autoinstaller": "^1.3.1",
"randomcolor": "^0.5.4",
"raw-loader": "^3.0.0",
"react": "^16.8.6",
"react-autocomplete": "^1.8.1",
"react-dom": "^16.8.6",
"react-geocoder-mapbox": "^2.5.12",
"react-google-recaptcha": "^1.0.5",
"react-helmet": "^5.2.1",
"react-loading-skeleton": "^1.1.2",
"react-map-gl": "^5.0.3",
"react-map-gl-geocoder": "^2.0.5",
"react-mapbox-gl-geocoder": "^1.0.3",
"react-modal": "^3.8.2",
"react-redux": "^7.1.0",
"react-router-dom": "^5.0.1",
"react-router-ga": "^1.2.0",
"react-router-hash-link": "^1.2.1",
"react-scripts": "^3.0.1",
"react-text-loop": "^2.0.2",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0",
"uikit": "^3.1.6"
}
}
答案 0 :(得分:0)
在您的const AWS = require('aws-sdk');
const ec2 = new AWS.EC2({ region: event.instanceRegion });
ec2.ModifyVolume({ VolumeId: [event.volumeId] , VolumeType: [event.VolumeType] });
中,您有两个软件包。
package.json
They are the same package,但最后一个是先前版本。
您还需要更新{
"@babel/core": "^7.5.4",
...
"babel-core": "^6.26.3",
}
babel-loader
将起作用。
答案 1 :(得分:0)
我同意@Vencovsky的观点,即可以将"babel-core": "^6.26.3"
更新为"@babel/core": "^7.5.4"
。您要做的一件事就是将导入行也更新为@babel/core
,无论您在哪里使用它。
答案 2 :(得分:0)
当我实际上将babel-cli更改为版本7时,它对我有用,所以也许问题出在
答案 3 :(得分:0)
您可能需要babel 7网桥作为babel-core
的版本
"babel-core": "^7.0.0-bridge.0"
在您的package.json
您可以检查package-lock.json
并查看其中安装了哪个版本的babel-core
。如果仍在安装6.26.3
,则可能还有另一个软件包,该软件包也需要更新该特定版本。就我而言,它是jest
以及最新版本的babelify
支持babel 7
来阻止它在我的package-lock.json
中安装较旧的babel版本。听起来也确实需要从该错误消息中更新babel-loader
的版本。