admin管理员组文章数量:1026683
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:
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:
test: /\.(js|jsx)$/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
'@babel/preset-react',
{
plugins: [
'@babel/plugin-proposal-class-properties'
]
}
],
pact: 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. Can anyone see any obvious mistakes I am making?
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:
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:
test: /\.(js|jsx)$/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
'@babel/preset-react',
{
plugins: [
'@babel/plugin-proposal-class-properties'
]
}
],
pact: 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. Can anyone see any obvious mistakes I am making?
Share Improve this question asked Jun 2, 2020 at 12:51 Thomas AllenThomas Allen 8118 gold badges18 silver badges33 bronze badges1 Answer
Reset to default 5The SyntaxError: Unexpected token ...
implies that your node isn't transpiling ES6. Have you upgraded node/npm to relatively new versions?
Also, if you're changing versions, I would suggest deleting your node_modules
folder and package-lock.json
file before running npm install
again.
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:
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:
test: /\.(js|jsx)$/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
'@babel/preset-react',
{
plugins: [
'@babel/plugin-proposal-class-properties'
]
}
],
pact: 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. Can anyone see any obvious mistakes I am making?
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:
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:
test: /\.(js|jsx)$/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
'@babel/preset-react',
{
plugins: [
'@babel/plugin-proposal-class-properties'
]
}
],
pact: 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. Can anyone see any obvious mistakes I am making?
Share Improve this question asked Jun 2, 2020 at 12:51 Thomas AllenThomas Allen 8118 gold badges18 silver badges33 bronze badges1 Answer
Reset to default 5The SyntaxError: Unexpected token ...
implies that your node isn't transpiling ES6. Have you upgraded node/npm to relatively new versions?
Also, if you're changing versions, I would suggest deleting your node_modules
folder and package-lock.json
file before running npm install
again.
本文标签: javascriptBabelLoader Syntax error on npm run buildStack Overflow
版权声明:本文标题:javascript - Babel-Loader Syntax error on npm run build - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745650369a2161281.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论