【发布时间】:2016-04-04 22:56:24
【问题描述】:
当我推送到 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;
有什么建议吗?谢谢
【问题讨论】:
-
执行
npm i babel-loader -D或npm install babel-loader --save-dev重新安装babel-loader
标签: javascript node.js heroku webpack