Я использую babel / browserify с gulp и composer.
Когда я использую const, это вызывает следующую ошибку в gulp
(node:15308) UnhandledPromiseRejectionWarning: TypeError: C:\xampp\htdocs\plugin\wp-content\plugins\nsp-adhesion\src\js\form.js: Cannot read property 'bindings' of null while parsing file: C:\xampp\htdocs\plugin\wp-content\plugins\nsp-adhesion\src\js\form.js
at Scope.moveBindingTo (C:\xampp\htdocs\plugin\wp-content\plugins\nsp-adhesion\node_modules\@babel\traverse\lib\scope\index.js:926:13)
at convertBlockScopedToVar (C:\xampp\htdocs\plugin\wp-content\plugins\nsp-adhesion\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:139:13)
at PluginPass.VariableDeclaration (C:\xampp\htdocs\plugin\wp-content\plugins\nsp-adhesion\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:26:9)
at newFn (C:\xampp\htdocs\plugin\wp-content\plugins\nsp-adhesion\node_modules\@babel\traverse\lib\visitors.js:179:21)
at NodePath._call (C:\xampp\htdocs\plugin\wp-content\plugins\nsp-adhesion\node_modules\@babel\traverse\lib\path\context.js:55:20)
at NodePath.call (C:\xampp\htdocs\plugin\wp-content\plugins\nsp-adhesion\node_modules\@babel\traverse\lib\path\context.js:42:17)
at NodePath.visit (C:\xampp\htdocs\plugin\wp-content\plugins\nsp-adhesion\node_modules\@babel\traverse\lib\path\context.js:90:31)
at TraversalContext.visitQueue (C:\xampp\htdocs\plugin\wp-content\plugins\nsp-adhesion\node_modules\@babel\traverse\lib\context.js:112:16)
at TraversalContext.visitMultiple (C:\xampp\htdocs\plugin\wp-content\plugins\nsp-adhesion\node_modules\@babel\traverse\lib\context.js:79:17)
at TraversalContext.visit (C:\xampp\htdocs\plugin\wp-content\plugins\nsp-adhesion\node_modules\@babel\traverse\lib\context.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";
});
Это нормальное поведение?