@Radiss

Webpack Как решить ошибку с babel — Cannot read property 'bindings' of null at Scope.moveBindingTo?

Возникла ошибка при настройке окружения Es6

Консоль
spoiler

<code lang="php">
$ webpack
Hash: acd90fe8f4a9db353ef2
Version: webpack 2.7.0
Time: 7294ms
     Asset       Size  Chunks             Chunk Names
 bundle.js    4.69 kB       0  [emitted]  main
index.html  182 bytes          [emitted]
   [0] ./index.js 2.06 kB {0} [built] [failed] [1 error]

ERROR in ./index.js
Module build failed: TypeError: Cannot read property 'bindings' of null
    at Scope.moveBindingTo (D:\ASITES\webpack\node_modules\@babel\traverse\lib\scope\index.js:864:13)
    at BlockScoping.updateScopeInfo (D:\ASITES\webpack\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:364:17)
    at BlockScoping.run (D:\ASITES\webpack\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:330:12)
    at PluginPass.BlockStatementSwitchStatementProgram (D:\ASITES\webpack\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:70:24)
    at newFn (D:\ASITES\webpack\node_modules\@babel\traverse\lib\visitors.js:193:21)
    at NodePath._call (D:\ASITES\webpack\node_modules\@babel\traverse\lib\path\context.js:53:20)
    at NodePath.call (D:\ASITES\webpack\node_modules\@babel\traverse\lib\path\context.js:40:17)
    at NodePath.visit (D:\ASITES\webpack\node_modules\@babel\traverse\lib\path\context.js:88:12)
    at TraversalContext.visitQueue (D:\ASITES\webpack\node_modules\@babel\traverse\lib\context.js:118:16)
    at TraversalContext.visitSingle (D:\ASITES\webpack\node_modules\@babel\traverse\lib\context.js:90:19)
    at TraversalContext.visit (D:\ASITES\webpack\node_modules\@babel\traverse\lib\context.js:146:19)
    at Function.traverse.node (D:\ASITES\webpack\node_modules\@babel\traverse\lib\index.js:94:17)
    at traverse (D:\ASITES\webpack\node_modules\@babel\traverse\lib\index.js:76:12)
    at transformFile (D:\ASITES\webpack\node_modules\@babel\core\lib\transformation\index.js:88:29)
    at runSync (D:\ASITES\webpack\node_modules\@babel\core\lib\transformation\index.js:45:3)
    at runAsync (D:\ASITES\webpack\node_modules\@babel\core\lib\transformation\index.js:35:14)
    at process.nextTick (D:\ASITES\webpack\node_modules\@babel\core\lib\transform.js:34:34)
    at process._tickCallback (internal/process/next_tick.js:61:11)
Child html-webpack-plugin for "index.html":
       [0] ./~/lodash/lodash.js 541 kB {0} [built]
       [1] ./~/html-webpack-plugin/lib/loader.js!./~/html-webpack-plugin/default_index.ejs 538 bytes {0} [built]
       [2] (webpack)/buildin/global.js 509 bytes {0} [built]
       [3] (webpack)/buildin/module.js 517 bytes {0} [built]
</code>




package.json
spoiler

{
  "name": "es6-theory-course",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/core": "^7.5.5",
    "babel-loader": "^8.0.6",
    "babel-preset-env": "^1.7.0",
    "html-webpack-plugin": "^2.30.1",
    "webpack": "^2.7.0"
  }
}




webpack.config

spoiler

var webpack = require('webpack');
var path = require('path');
var HtmlPlugin = require('html-webpack-plugin');


module.exports = {

    entry: './index.js',

    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js'
    },

    plugins: [
        new HtmlPlugin()
    ],

   module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /(node_modules|bower_components)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['env']
                    }
                }
            }
        ]
    }

};


  • Вопрос задан
  • 624 просмотра
Решения вопроса 1
@Radiss Автор вопроса
В webpack.config вместо presets: ['env'] добавить presets: ['@babel/preset-env']

module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /(node_modules|bower_components)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env']
                    }
                }
            }
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
bingo347
@bingo347
Crazy on performance...
npm rm -D babel-preset-env
npm i -D @babel/preset-env
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы