node -v): v7.6.0 npm -v): 4.3.0npm run production (or any of the other scripts) fails after 90% and the most relevant log message is "Exit status 2".
It runs fine on my ubuntu VM, but not on my production server. I'm using deployer.php for what it's worth.
npm verb lifecycle @~production: unsafe-perm in lifecycle true
npm verb lifecycle @~production: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/lemp/www/app-staging/releases/1/node_modules/.bin:/usr/local/sb
in:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
npm verb lifecycle @~production: CWD: /www/app-staging/releases/1
npm info lifecycle @~production: Failed to exec production script
npm verb stack Error: @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/l
aravel-mix/setup/webpack.config.js`
npm verb stack Exit status 2
npm verb stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
npm verb stack at emitTwo (events.js:106:13)
npm verb stack at EventEmitter.emit (events.js:192:7)
npm verb stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
npm verb stack at emitTwo (events.js:106:13)
npm verb stack at ChildProcess.emit (events.js:192:7)
npm verb stack at maybeClose (internal/child_process.js:890:16)
npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npm verb pkgid @
npm verb cwd /www/app-staging/releases/1
npm ERR! Linux 3.13.0-101-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "production" "--verbose"
npm ERR! node v7.6.0
npm ERR! npm v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/se
tup/webpack.config.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @ production script 'cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_mo
dules/laravel-mix/setup/webpack.config.js'.
yes
After some hair pulling, instead of npm run production I used the entire command directly in my deploy script:
node_modules/webpack/bin/webpack.js --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
I also had to remove --progress to make it work. And NODE_ENV=production doesn't seem to have any effect either, as my assets are not getting minified.
Hello,
I also had this trouble yesterday
Please try this package.json file
{
"private": true,
"scripts": {
"dev": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch-poll": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"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"
},
"devDependencies": {
"axios": "^0.15.3",
"bootstrap-sass": "^3.3.7",
"jquery": "^3.1.1",
"laravel-mix": "^0.8.1",
"lodash": "^4.17.4",
"vue": "^2.1.10"
},
"dependencies": {
}
}
In devDependencies, you can specify _cross-env_, laravel-mix is shipping with it. I removed it on my test env since it's required by Laravel-mix.
@cybermania Thanks, but I'm already using cross-env.
@JeffreyWay Can you shed some light on what could be happening here? I'm on Windows with Homestead and my deploy script is fired directly from the vm.
In the end, --quiet was all I needed.
Is it possible it was a permissions issue? I think I am seeing something like this when Mix can't write to one or more of the destination files (e.g. the public/css/app.css file)
Most helpful comment
yes