错误:尽管已安装了Babel polyfill,但仍需要它

时间:2016-02-03 11:45:03

标签: javascript reactjs webpack babeljs

在webpack中安装bootstrap-loader后,我收到此错误:

ERROR in 
      For Node <= v0.12.x Babel polyfill is required.
      Make sure it's installed in your 'node_modules/' directory.

 @ /Users/user/~/bootstrap-loader/loader.js 1:0-44 

虽然我已经安装了babel polyfill并包含在webpack.config.js中。我没有创建node_modules文件夹。

Webpack.config.js

var webpack = require('webpack');
var path = require('path');

var BUILD_DIR = path.resolve(__dirname, 'build');
var APP_DIR = path.resolve(__dirname, 'src');

module.exports = {
    entry: [
        // Set up an ES6-ish environment
        'babel-polyfill',
        'bootstrap-loader',
        APP_DIR + '/import.js',
    ],
    output: {
        path: BUILD_DIR,
        filename: 'bundle.js'
    },
    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                loader: 'babel',

                exclude: /node_modules/,
                query: {
                    plugins: ['transform-runtime'],
                    presets: ['es2015', 'stage-0', 'react']
                }
            },
            {
                test: /\.css$/,
                loader: "style-loader!css-loader"
            }
        ]
    },
    plugins: [
        new webpack.ProvidePlugin({
            $: "jquery",
            jQuery: "jquery"
        })
    ]
};

1 个答案:

答案 0 :(得分:1)

我通过更新我的nodejs版本解决了这个问题。以前我有 0.10.x ,我安装 5.5.0

请参阅Installing Nodejs via Package-Manager了解如何安装它。