使用以下配置获得上述错误,注释passPerPreset会删除错误。是否缺少任何配置?
.babelrc:
{
"passPerPreset": true,
"presets": [{
"plugins": [
"./build/babelRelayPlugin",
"transform-runtime",
"transform-es2015-classes"
]
}, "es2015", "stage-0", "react"],
"env": {
"development": {
"presets": ["react-hmre"]
}
}
}
package.json:
"babel-cli": "^6.5.1",
"babel-core": "^6.5.2",
"babel-eslint": "^4.1.8",
"babel-loader": "^6.2.2",
"babel-plugin-react-transform": "^2.0.0",
"babel-plugin-transform-es2015-classes": "^6.5.2",
"babel-plugin-transform-runtime": "^6.5.2",
"babel-polyfill": "^6.5.0",
"babel-preset-es2015": "^6.5.0",
"babel-preset-react": "^6.5.0",
"babel-preset-react-hmre": "^1.1.0",
"babel-preset-stage-0": "^6.5.0",
"babel-relay-plugin": "^0.7.0",
"babel-runtime": "^6.5.0",
Webpack:
module: {
loaders: [
{
loader: "babel-loader",
include: [
path.resolve(__dirname, "app"),
],
test: /\.jsx?$/,
query: {
plugins: ['transform-runtime'],
presets: ['react', 'es2015', 'stage-0'],
}
},
]
},
错误:babel-node start
Module build failed: Error: Plugin 0 specified in "/Users/my/demo/node_modules/babel-preset-es2015/index.js" provided an invalid property of "_c"
答案 0 :(得分:6)
对我有用的是:
rm -rf node_modules
npm prune
npm cache clear
npm cache clean
npm i
答案 1 :(得分:6)
升级babel-core
和babel-loader
为我解决了此问题。
npm install --save babel-core@latest babel-loader@latest
答案 2 :(得分:0)
我认为您在.babelrc
中指定的内容与babel-loader
中的内容之间可能存在争用。
您可以尝试从Webpack配置中删除query
吗?
答案 3 :(得分:0)
我遇到了同样的问题,但是像Alex建议的那样删除和重建node_modules对我来说没有帮助。
原来,有些软件包的版本不匹配。当我从package.json
删除所有依赖项和 devDependencies 并分别通过npm i -S
或npm i -D
再次添加它们时,一切都开始起作用试。
答案 4 :(得分:0)
清除我的node_modules
等没有用。但是,评论passPerPreset
做了伎俩。 TBH我不确定那个选项是做什么的,但大多数谷歌点击它都是错误报告,所以只要它有效,我就没问题。
// babelrc
{
//"passPerPreset": true,
"presets": [
"stage-0",
"react-app"
],
"plugins": [
"transform-runtime",
"syntax-async-functions",
"transform-decorators-legacy",
"transform-class-properties",
"react-relay"
]
}
答案 5 :(得分:0)
更新我的npm版本解决了这个问题。