当我推送到heroku时,我正试图在我的package.json中的postinstall脚本上运行webpack,但是我收到以下错误.
ERROR in Entry module not found: Error: Cannot resolve module 'babel-loader' in /tmp/build_6cb4b10367d9382367ab72f2e2f33118
当我在本地运行命令时,我没有遇到任何问题.下面是我的webpack配置 - 我尝试使用resolveLoader来解决解决问题,但无济于事?
var path = require('path'); var webpack = require('webpack'); var config = { entry: path.resolve(__dirname, './app/main.js'), output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js' }, module: { loaders: [ { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }, { test: /\.less$/, loader: 'style!css!less' }] }, resolve: { extensions: ['', '.js', '.jsx', '.less'], modulesDirectories: [ 'node_modules' ] }, resolveLoader: { root: path.resolve(__dirname, 'node_modules') }, plugins: [ new webpack.optimize.UglifyJsPlugin({minimize: true}) ] }; module.exports = config;
有什么建议?谢谢
我发现了原因.我的package.json中没有babel或babel-core.添加它们修复了错误.
"devDependencies": { "babel": "^5.8.23", "babel-core": "^5.0.0", "babel-loader": "^5.3.2" }
在我的情况下,我在安装时错误拼写了装载程序,所以请确保安装
巴贝尔装载机
不
巴布尔装载机