使用 'const' 关键字会在 babel 中触发错误



我将babel/browsrify与gull和composer一起使用。

当我使用const时,它会在gullow 中触发以下错误

(node:15308) UnhandledPromiseRejectionWarning: TypeError: C:xampphtdocspluginwp-contentpluginsnsp-adhesionsrcjsform.js: Cannot read property 'bindings' of null while parsing file: C:xampphtdocspluginwp-contentpluginsnsp-adhesionsrcjsform.js
at Scope.moveBindingTo (C:xampphtdocspluginwp-contentpluginsnsp-adhesionnode_modules@babeltraverselibscopeindex.js:926:13)
at convertBlockScopedToVar (C:xampphtdocspluginwp-contentpluginsnsp-adhesionnode_modulesbabel-plugin-transform-es2015-block-scopinglibindex.js:139:13)
at PluginPass.VariableDeclaration (C:xampphtdocspluginwp-contentpluginsnsp-adhesionnode_modulesbabel-plugin-transform-es2015-block-scopinglibindex.js:26:9)
at newFn (C:xampphtdocspluginwp-contentpluginsnsp-adhesionnode_modules@babeltraverselibvisitors.js:179:21)
at NodePath._call (C:xampphtdocspluginwp-contentpluginsnsp-adhesionnode_modules@babeltraverselibpathcontext.js:55:20)
at NodePath.call (C:xampphtdocspluginwp-contentpluginsnsp-adhesionnode_modules@babeltraverselibpathcontext.js:42:17)
at NodePath.visit (C:xampphtdocspluginwp-contentpluginsnsp-adhesionnode_modules@babeltraverselibpathcontext.js:90:31)
at TraversalContext.visitQueue (C:xampphtdocspluginwp-contentpluginsnsp-adhesionnode_modules@babeltraverselibcontext.js:112:16)
at TraversalContext.visitMultiple (C:xampphtdocspluginwp-contentpluginsnsp-adhesionnode_modules@babeltraverselibcontext.js:79:17)
at TraversalContext.visit (C:xampphtdocspluginwp-contentpluginsnsp-adhesionnode_modules@babeltraverselibcontext.js:138:19)
(node:15308) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:15308) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

只有包裹在中才能工作

document.addEventListener('DOMContentLoaded', function(e) {
// global variables
const test = "test";    
});

这是正常行为吗?

在这篇文章中找到了答案,

是6&7

JavaScript babel";TypeError:无法读取属性';绑定';"为空";当试图转换时

相关内容

最新更新