admin管理员组文章数量:1134570
I just upgraded to Babel 7 (from 6) by running these commands:
npm remove babel-cli
npm install --save-dev @babel/cli @babel/core @babel/preset-env
Here is my .babelrc
file:
{ "presets": ["env"] }
Then I ran:
babel js/src --out-dir js/dist
And it results in:
TypeError: Cannot read property 'bindings' of null
at Scope.moveBindingTo (/xyz/node_modules/@babel/traverse/lib/scope/index.js:867:13)
at BlockScoping.updateScopeInfo (/xyz/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17)
at BlockScoping.run (/xyz/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:330:12)
at PluginPass.BlockStatementSwitchStatementProgram (/xyz/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:70:24)
at newFn (/xyz/node_modules/@babel/traverse/lib/visitors.js:193:21)
at NodePath._call (/xyz/node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (/xyz/node_modules/@babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (/xyz/node_modules/@babel/traverse/lib/path/context.js:88:12)
at TraversalContext.visitQueue (/xyz/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitSingle (/xyz/node_modules/@babel/traverse/lib/context.js:90:19)
What did I do wrong?
I just upgraded to Babel 7 (from 6) by running these commands:
npm remove babel-cli
npm install --save-dev @babel/cli @babel/core @babel/preset-env
Here is my .babelrc
file:
{ "presets": ["env"] }
Then I ran:
babel js/src --out-dir js/dist
And it results in:
TypeError: Cannot read property 'bindings' of null
at Scope.moveBindingTo (/xyz/node_modules/@babel/traverse/lib/scope/index.js:867:13)
at BlockScoping.updateScopeInfo (/xyz/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17)
at BlockScoping.run (/xyz/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:330:12)
at PluginPass.BlockStatementSwitchStatementProgram (/xyz/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:70:24)
at newFn (/xyz/node_modules/@babel/traverse/lib/visitors.js:193:21)
at NodePath._call (/xyz/node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (/xyz/node_modules/@babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (/xyz/node_modules/@babel/traverse/lib/path/context.js:88:12)
at TraversalContext.visitQueue (/xyz/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitSingle (/xyz/node_modules/@babel/traverse/lib/context.js:90:19)
What did I do wrong?
Share Improve this question edited Nov 6, 2018 at 13:14 ndequeker 7,9907 gold badges62 silver badges94 bronze badges asked Aug 30, 2018 at 8:45 rap-2-hrap-2-h 31.9k46 gold badges185 silver badges280 bronze badges1 Answer
Reset to default 382In your .babelrc
file, change
{ "presets": ["env"] }
to
{ "presets": ["@babel/preset-env"] }
(and install that package if you haven't already).
In your .babelrc
you are still referencing the package babel-preset-env
(which is for 6.x), you want to reference @babel/preset-env
instead (which is for 7.x).
https://github.com/babel/babel/issues/6186#issuecomment-366556833
Note: you should also make this change in webpack.config.js
if it is there as well.
Here is the sample webpack config section where you should change the preset:
use: {
loader: 'babel-loader',
options: {
// Here you should change 'env' to '@babel/preset-env'
presets: ['@babel/preset-env'],
},
},
本文标签: javascriptUpgrade to Babel 7 Cannot read property 39bindings39 of nullStack Overflow
版权声明:本文标题:javascript - Upgrade to Babel 7: Cannot read property 'bindings' of null - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736818986a1954207.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论