使用webpack和babel时报错

初学webpack,用babel将es6转化为es5时报错:


ERROR in ./entry.js

Module build failed: Error: Cannot find module 'core-js/library/fn/get-iterator'

重装babel-core也不管用


webpack配置为:


module.exports = {

    entry: './entry.js',

    output: {

        filename: 'bundle.js'

    },

    //devtool: 'source-map',

    module: {

        loaders: [{

            test: /\.css$/,

            loader: 'style-loader!css-loader'

        },{

            test: /\.js$/,

            exclude: /node_modules/,

            loader: 'babel-loader'

        }]

    }

}

.babelrc内容为:


{

"presets": ["es2015"]

}

entry.js为:


var a = require('./a.js');

require('./index.css');


let app = document.getElementById('app');

app.innerHTML = '<p>hello webpack!</p>' + a.a;


眼眸繁星
浏览 701回答 1
1回答

慕沐林林

答案网上很多,但是可以告诉你的是 babel 即便把es6转换成es5 兼容ie的时候 也会有问题...慎用
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript