我想构建我的应用程序,但是我收到了以下错误消息:
ERROR in ./src/index.js
Module build failed: Error: Couldn't find preset "@babel/env" relative to directory "/Users/mohammadmehdi/Documents/Work/sevenapp"
at /Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
at Array.map (<anonymous>)
at OptionManager.resolvePresets (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
at OptionManager.mergePresets (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
at OptionManager.mergeOptions (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
at OptionManager.init (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at transpile (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-loader/lib/index.js:50:20)
at Object.module.exports (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-loader/lib/index.js:173:20)
my package.json:
{
"name": "sevenapp",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"babel-preset-react": "^6.24.1",
"bootstrap": "^4.0.0",
"html-webpack-plugin": "^3.2.0",
"jquery": "^3.3.1",
"rc-pagination": "^1.16.4",
"react": "^16.2.0",
"react-countup": "^3.0.3",
"react-dom": "^16.2.0",
"react-paginate": "^5.2.3",
"react-player": "^1.6.4",
"react-popup": "^0.9.3",
"react-redux": "^5.0.7",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-scripts": "1.1.1",
"redux": "^4.0.0"
},
"scripts": {
"start": "webpack-dev-server --mode development --open",
"build": "webpack --mode production",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"description": ":D",
"main": "index.js",
"devDependencies": {
"@babel/preset-env": "^7.0.0-beta.51",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-3": "^6.24.1",
"css-loader": "^0.28.11",
"jshint": "^2.9.5",
"jshint-loader": "^0.8.4",
"style-loader": "^0.21.0",
"url-loader": "^1.0.1",
"webpack": "^4.6.0",
"webpack-cli": "^2.0.15"
},
"author": "MM",
"license": "ISC"
}
我的.babelrc
文件:
{
"presets": [
"@babel/env",
"@babel/preset-react",
[
"@babel/preset-stage-3",
{
"decoratorsLegacy": true
}
]
]
}
我的问题出在哪里?
我的操作系统是macOS HighSierra 10.13.3,Node.js版本是10,React版本是16.2。
Node.js版本为10,Webpack版本为4,NPM版本为6.0.1。
但是我却找不到"@babel/env"预设。
怎样解决这个问题?