我的项目在具有生产环境的本地计算机上构建并运行得很好,但是当我将其部署到服务器并运行“ npm run production”时,它停留在92%,然后抛出错误:
Executing pre-build scripts
92% chunk asset optimization TerserPluginnpm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ production: node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-07-29T10_50_55_510Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ prod: npm run production
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-07-29T10_50_55_538Z-debug.log
这是我的webpack.mix.js:
const mix = require('laravel-mix');
const WebpackShellPlugin = require('webpack-shell-plugin');
const FontminPlugin = require('fontmin-webpack');
mix.options({
terser: {
sourceMap: true,
parallel: true,
},
});
mix.sourceMaps().webpackConfig({devtool: 'source-map'});
if(process.env.NODE_ENV === 'production') {
mix.version();
}
mix.webpackConfig({
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.jsx$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.(woff|ttf|eot|svg)(\?v=[a-z0-9]\.[a-z0-9]\.[a-z0-9])?$/,
loader: 'file-loader'
}
]
}
});
mix.webpackConfig({
plugins: [
new FontminPlugin({
autodetect: true
}),
new WebpackShellPlugin({onBuildStart:['php artisan lang:js public/js/message.js --quiet'], onBuildEnd:['php artisan laroute:generate --quiet']}),
]
});
mix.sass('resources/assets/app.scss', 'public/css/app.css').options({
postCss: [
require('autoprefixer')()
]
}).react([
'resources/assets/js/app.js'
], 'public/js/app.js');
mix.extract();
我的节点版本:10.16,我的npm版本:6.9.0。我尝试将并行方式从true更改为false,但仍然会遇到相同的错误。 “ npm run dev”在我的服务器上运行良好,因此这可能是开发构建问题