admin管理员组文章数量:1023018
I'm using Babel (7.5.0) and NodeJS latest (12.x), so the spread operator is already handled by NodeJS and I don't want babel to mess with it.
This is my .babelrc :
{
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
],
"presets": [
[
"@babel/preset-env",
{
"modules": "monjs",
"targets": {
"node": "current"
},
"useBuiltIns": "usage"
}
]
]
}
This is my error :
ERROR in ./src/utils/logger/logger.js
Module build failed: ReferenceError: Unknown helper objectSpread2
at loadHelper (/app/node_modules/@babel/helpers/lib/index.js:238:27)
at Object.getDependencies (/app/node_modules/@babel/helpers/lib/index.js:279:21)
at File.addHelper (/app/node_modules/@babel/core/lib/transformation/file/file.js:204:33)
at PluginPass.addHelper (/app/node_modules/@babel/core/lib/transformation/plugin-pass.js:31:22)
at PluginPass.ObjectExpression (/app/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js:379:25)
at newFn (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/visitors.js:193:21)
at NodePath._call (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:88:12)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitSingle (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:90:19)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:146:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
@ ./src/app.js 5:0-40
@ multi ./src/app.js
I've read that I need to install some plugin, but I think that's for older nodejs versions, I don't see why I need a plugin for a feature built-in nodejs.
How can I do that?
Update:
I created an issue there :
I'm using Babel (7.5.0) and NodeJS latest (12.x), so the spread operator is already handled by NodeJS and I don't want babel to mess with it.
This is my .babelrc :
{
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
],
"presets": [
[
"@babel/preset-env",
{
"modules": "monjs",
"targets": {
"node": "current"
},
"useBuiltIns": "usage"
}
]
]
}
This is my error :
ERROR in ./src/utils/logger/logger.js
Module build failed: ReferenceError: Unknown helper objectSpread2
at loadHelper (/app/node_modules/@babel/helpers/lib/index.js:238:27)
at Object.getDependencies (/app/node_modules/@babel/helpers/lib/index.js:279:21)
at File.addHelper (/app/node_modules/@babel/core/lib/transformation/file/file.js:204:33)
at PluginPass.addHelper (/app/node_modules/@babel/core/lib/transformation/plugin-pass.js:31:22)
at PluginPass.ObjectExpression (/app/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js:379:25)
at newFn (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/visitors.js:193:21)
at NodePath._call (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:88:12)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitSingle (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:90:19)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:146:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
@ ./src/app.js 5:0-40
@ multi ./src/app.js
I've read that I need to install some plugin, but I think that's for older nodejs versions, I don't see why I need a plugin for a feature built-in nodejs.
How can I do that?
Update:
I created an issue there : https://github./babel/babel-loader/issues/798
Share Improve this question edited Jul 9, 2019 at 9:59 HRK44 asked Jul 5, 2019 at 10:05 HRK44HRK44 2,7823 gold badges14 silver badges33 bronze badges 7-
this plugin
"transform-object-rest-spread"
enables spread operator. I am not sure if some feature is already built in then why we have to use some plugin to use that feature. – Usama Tahir Commented Jul 5, 2019 at 10:09 - 1 Do I have to use this plugin? Even with NodeJS 12.x ? – HRK44 Commented Jul 5, 2019 at 10:42
- 1 I am not sure. I didn't check it. let me dig into it and I will add a ment about my findings here. – Usama Tahir Commented Jul 5, 2019 at 10:44
-
I can successfully use
spread
operator in node versionv10.16.0
. – Usama Tahir Commented Jul 5, 2019 at 10:52 -
So you mean that it does not work with Node
v12.x
but works fine withv10.16.0
? – Bilal Commented Jul 5, 2019 at 13:55
1 Answer
Reset to default 7Babel maintainer here.
We have a bug in v7.5.0 (it will soon be fixed in v7.5.1). You have two possible workaround:
- Run
npm install @babel/helpers
(or with yarn): this will force npm to download@babel/helpers
v7.5.0, which contains the missing helper. If you are also using@babel/transform-runtime
, make usre that@babel/runtime
is v7.5.0 If you are using yarn, you can lock
@babel/plugin-proposal-object-rest-spread
to an older version which isn't affected by the issue. Add this code to your package.json:"resolutions": { "**/@babel/plugin-proposal-object-rest-spread": "7.4.4" }
EDIT This should be fixed in v7.5.1, please update
I'm using Babel (7.5.0) and NodeJS latest (12.x), so the spread operator is already handled by NodeJS and I don't want babel to mess with it.
This is my .babelrc :
{
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
],
"presets": [
[
"@babel/preset-env",
{
"modules": "monjs",
"targets": {
"node": "current"
},
"useBuiltIns": "usage"
}
]
]
}
This is my error :
ERROR in ./src/utils/logger/logger.js
Module build failed: ReferenceError: Unknown helper objectSpread2
at loadHelper (/app/node_modules/@babel/helpers/lib/index.js:238:27)
at Object.getDependencies (/app/node_modules/@babel/helpers/lib/index.js:279:21)
at File.addHelper (/app/node_modules/@babel/core/lib/transformation/file/file.js:204:33)
at PluginPass.addHelper (/app/node_modules/@babel/core/lib/transformation/plugin-pass.js:31:22)
at PluginPass.ObjectExpression (/app/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js:379:25)
at newFn (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/visitors.js:193:21)
at NodePath._call (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:88:12)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitSingle (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:90:19)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:146:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
@ ./src/app.js 5:0-40
@ multi ./src/app.js
I've read that I need to install some plugin, but I think that's for older nodejs versions, I don't see why I need a plugin for a feature built-in nodejs.
How can I do that?
Update:
I created an issue there :
I'm using Babel (7.5.0) and NodeJS latest (12.x), so the spread operator is already handled by NodeJS and I don't want babel to mess with it.
This is my .babelrc :
{
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
],
"presets": [
[
"@babel/preset-env",
{
"modules": "monjs",
"targets": {
"node": "current"
},
"useBuiltIns": "usage"
}
]
]
}
This is my error :
ERROR in ./src/utils/logger/logger.js
Module build failed: ReferenceError: Unknown helper objectSpread2
at loadHelper (/app/node_modules/@babel/helpers/lib/index.js:238:27)
at Object.getDependencies (/app/node_modules/@babel/helpers/lib/index.js:279:21)
at File.addHelper (/app/node_modules/@babel/core/lib/transformation/file/file.js:204:33)
at PluginPass.addHelper (/app/node_modules/@babel/core/lib/transformation/plugin-pass.js:31:22)
at PluginPass.ObjectExpression (/app/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js:379:25)
at newFn (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/visitors.js:193:21)
at NodePath._call (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:88:12)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitSingle (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:90:19)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:146:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
@ ./src/app.js 5:0-40
@ multi ./src/app.js
I've read that I need to install some plugin, but I think that's for older nodejs versions, I don't see why I need a plugin for a feature built-in nodejs.
How can I do that?
Update:
I created an issue there : https://github./babel/babel-loader/issues/798
Share Improve this question edited Jul 9, 2019 at 9:59 HRK44 asked Jul 5, 2019 at 10:05 HRK44HRK44 2,7823 gold badges14 silver badges33 bronze badges 7-
this plugin
"transform-object-rest-spread"
enables spread operator. I am not sure if some feature is already built in then why we have to use some plugin to use that feature. – Usama Tahir Commented Jul 5, 2019 at 10:09 - 1 Do I have to use this plugin? Even with NodeJS 12.x ? – HRK44 Commented Jul 5, 2019 at 10:42
- 1 I am not sure. I didn't check it. let me dig into it and I will add a ment about my findings here. – Usama Tahir Commented Jul 5, 2019 at 10:44
-
I can successfully use
spread
operator in node versionv10.16.0
. – Usama Tahir Commented Jul 5, 2019 at 10:52 -
So you mean that it does not work with Node
v12.x
but works fine withv10.16.0
? – Bilal Commented Jul 5, 2019 at 13:55
1 Answer
Reset to default 7Babel maintainer here.
We have a bug in v7.5.0 (it will soon be fixed in v7.5.1). You have two possible workaround:
- Run
npm install @babel/helpers
(or with yarn): this will force npm to download@babel/helpers
v7.5.0, which contains the missing helper. If you are also using@babel/transform-runtime
, make usre that@babel/runtime
is v7.5.0 If you are using yarn, you can lock
@babel/plugin-proposal-object-rest-spread
to an older version which isn't affected by the issue. Add this code to your package.json:"resolutions": { "**/@babel/plugin-proposal-object-rest-spread": "7.4.4" }
EDIT This should be fixed in v7.5.1, please update
本文标签: javascriptBabel with NodeJS not working spread operatorStack Overflow
版权声明:本文标题:javascript - Babel with NodeJS not working spread operator - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745579868a2157243.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论