[英]Babel-Loader Syntax error on npm run build
I am not very strong with webpack and am trying to update webpack from V3 to V4 and have managed to update my webpack config to the point where its not throwing depreciation errors at me, but I am now stuck on a syntax error from babel-loader:我对 webpack 不是很强大,我正在尝试将 webpack 从 V3 更新到 V4,并设法将我的 webpack 配置更新到了从 babel-loader 出现的语法错误,但我现在没有在 babel-loader 上抛出语法错误:
Module build failed (from ./node_modules/babel-loader/lib/index.js):
/path/react/node_modules/schema-utils/dist/util/hints.js:16
const currentSchema = { ...schema
SyntaxError: Unexpected token ...
In my webpack config I have this:在我的 webpack 配置中,我有这个:
test: /\.(js|jsx)$/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
'@babel/preset-react',
{
plugins: [
'@babel/plugin-proposal-class-properties'
]
}
],
compact: true,
cacheDirectory: false, // @todo: legacy option: true
},
}
]
and I am using the following versions:我正在使用以下版本:
"@babel/core": "^7.1.6",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/preset-env": "^7.1.6",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.4",
I have tried multiple times with diffent versions of babel but always end up at this message.我曾多次尝试使用不同版本的 babel,但总是以这条消息结束。 Can anyone see any obvious mistakes I am making?
谁能看到我犯的任何明显错误?
The SyntaxError: Unexpected token...
implies that your node isn't transpiling ES6. SyntaxError: Unexpected token...
意味着您的节点没有转译 ES6。 Have you upgraded node/npm to relatively new versions?您是否将 node/npm 升级到相对较新的版本?
Also, if you're changing versions, I would suggest deleting your node_modules
folder and package-lock.json
file before running npm install
again.另外,如果您要更改版本,我建议您在再次运行
npm install
之前删除您的node_modules
文件夹和package-lock.json
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.