如何修复此错误?:模块构建失败(来自 ./node_modules/babel-loader/lib/index.js):
How Do I Fix This Error?: Module build failed (from ./node_modules/babel-loader/lib/index.js):
我正在使用 React 和 Express 构建一个项目。在尝试设置环境时,我不断收到错误消息。作为 babel 的新手,我决定在互联网上搜索解决方案,但我尝试过的任何方法都没有用。
我尝试卸载@babel/core & @babel/preset-env 并重新安装它们的更新版本 &
我尝试重新启动 VS 代码。
现在我完全被困住了。一些帮助将不胜感激。
错误:
ERROR in ./src/app/index.jsx
Module build failed (from ./node_modules/babel-loader/lib/index.js):
ReferenceError: Unknown option: .presents. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.
at throwUnknownError (C:\Users\Yanki XXIV\Desktop\pluralsight-project\node_modules\@babel\core\lib\config\validation\options.js:122:11)
at C:\Users\Yanki XXIV\Desktop\pluralsight-project\node_modules\@babel\core\lib\config\validation\options.js:106:5
at Array.forEach (<anonymous>)
at validateNested (C:\Users\Yanki XXIV\Desktop\pluralsight-project\node_modules\@babel\core\lib\config\validation\options.js:82:21)
at validate (C:\Users\Yanki XXIV\Desktop\pluralsight-project\node_modules\@babel\core\lib\config\validation\options.js:73:10)
at C:\Users\Yanki XXIV\Desktop\pluralsight-project\node_modules\@babel\core\lib\config\config-chain.js:169:34
at cachedFunction (C:\Users\Yanki XXIV\Desktop\pluralsight-project\node_modules\@babel\core\lib\config\caching.js:33:19)
sight-project\node_modules\@babel\core\lib\config\partial.js:82:18)
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/app main[1]
package.json
{
"name": "pluralsight-project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack",
"dev": "webpack-dev-server --open"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/node": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"babel-loader": "^8.0.2",
"webpack": "^4.17.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.7"
},
"dependencies": {
"react": "^16.4.2",
"react-dom": "^16.5.0",
"react-redux": "^5.0.7",
"redux": "^4.0.0"
}
}
错误还谈到 index.jsx,我不知道为什么,但这是文件,index.jsx:
import { store } from './store';
import React from 'react';
import ReactDOM from 'react-dom';
import { Main } from './components/Main'
ReactDOM.render(
< Main />,
document.getElementById("app")
)
bablrc:
{
"presents":[
["@babel/present-env", {
"targets": {
"node":"current"
}
}],
"@babel/present-react"
]
}
Babel 配置文件应该是:
{
"presets":[
["@babel/preset-env", {
"targets": {
"node":"current"
}
}],
"@babel/preset-react"
]
}
我正在使用 React 和 Express 构建一个项目。在尝试设置环境时,我不断收到错误消息。作为 babel 的新手,我决定在互联网上搜索解决方案,但我尝试过的任何方法都没有用。 我尝试卸载@babel/core & @babel/preset-env 并重新安装它们的更新版本 & 我尝试重新启动 VS 代码。 现在我完全被困住了。一些帮助将不胜感激。
错误:
ERROR in ./src/app/index.jsx
Module build failed (from ./node_modules/babel-loader/lib/index.js):
ReferenceError: Unknown option: .presents. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.
at throwUnknownError (C:\Users\Yanki XXIV\Desktop\pluralsight-project\node_modules\@babel\core\lib\config\validation\options.js:122:11)
at C:\Users\Yanki XXIV\Desktop\pluralsight-project\node_modules\@babel\core\lib\config\validation\options.js:106:5
at Array.forEach (<anonymous>)
at validateNested (C:\Users\Yanki XXIV\Desktop\pluralsight-project\node_modules\@babel\core\lib\config\validation\options.js:82:21)
at validate (C:\Users\Yanki XXIV\Desktop\pluralsight-project\node_modules\@babel\core\lib\config\validation\options.js:73:10)
at C:\Users\Yanki XXIV\Desktop\pluralsight-project\node_modules\@babel\core\lib\config\config-chain.js:169:34
at cachedFunction (C:\Users\Yanki XXIV\Desktop\pluralsight-project\node_modules\@babel\core\lib\config\caching.js:33:19)
sight-project\node_modules\@babel\core\lib\config\partial.js:82:18)
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/app main[1]
package.json
{
"name": "pluralsight-project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack",
"dev": "webpack-dev-server --open"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/node": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"babel-loader": "^8.0.2",
"webpack": "^4.17.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.7"
},
"dependencies": {
"react": "^16.4.2",
"react-dom": "^16.5.0",
"react-redux": "^5.0.7",
"redux": "^4.0.0"
}
}
错误还谈到 index.jsx,我不知道为什么,但这是文件,index.jsx:
import { store } from './store';
import React from 'react';
import ReactDOM from 'react-dom';
import { Main } from './components/Main'
ReactDOM.render(
< Main />,
document.getElementById("app")
)
bablrc:
{
"presents":[
["@babel/present-env", {
"targets": {
"node":"current"
}
}],
"@babel/present-react"
]
}
Babel 配置文件应该是:
{
"presets":[
["@babel/preset-env", {
"targets": {
"node":"current"
}
}],
"@babel/preset-react"
]
}