question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPM run prod error

See original GitHub issue
  • Laravel Mix Version: 1.6.1
  • Node Version (node -v): v8.9.0
  • NPM Version (npm -v): 5.5.1
  • OS: Mac os x high sierra

Description:

When running npm run dev everything works, but when running npm run prod I get the following error:

npm run prod

> @ prod /websites/laravel
> npm run production


> @ production /websites/laravel
> cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

/websites/laravel/node_modules/schema-utils/dist/validateOptions.js:40
    throw new _ValidationError2.default(ajv.errors, name);
    ^

false
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ production: `cross-env 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!     /.npm/_logs/2017-11-07T10_09_46_232Z-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!     /.npm/_logs/2017-11-07T10_09_46_249Z-debug.log

This is my package.json

{
  "private": true,
  "scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "npm run watch --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "cross-env": "^5.1",
    "laravel-echo": "^1.3.2",
    "laravel-mix": "^1.6.1",
    "less": "^2.7.3",
    "less-loader": "^4.0.5",
    "pusher-js": "^4.2.1"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ]
}

Here the NPM log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/8.9.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'prod' ]
2 info using npm@5.5.1
3 info using node@v8.9.0
4 verbose run-script [ 'preprod', 'prod', 'postprod' ]
5 info lifecycle @~preprod: @
6 info lifecycle @~prod: @
7 verbose lifecycle @~prod: unsafe-perm in lifecycle true
8 verbose lifecycle @~prod: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/websites/laravel/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/MacGPG2/bin:/usr/local/sbin:~/.composer/vendor/bin
9 verbose lifecycle @~prod: CWD: /websites/laravel/
10 silly lifecycle @~prod: Args: [ '-c', 'npm run production' ]
11 silly lifecycle @~prod: Returned: code: 1  signal: null
12 info lifecycle @~prod: Failed to exec prod script
13 verbose stack Error: @ prod: `npm run production`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:280:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid @
15 verbose cwd /websites/laravel
16 verbose Darwin 17.2.0
17 verbose argv "/usr/local/Cellar/node/8.9.0/bin/node" "/usr/local/bin/npm" "run" "prod"
18 verbose node v8.9.0
19 verbose npm  v5.5.1
20 error code ELIFECYCLE
21 error errno 1
22 error @ prod: `npm run production`
22 error Exit status 1
23 error Failed at the @ prod script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
spaceemotioncommented, Nov 9, 2017

Update: looking at the release notes Uglify seems to require the previous settings to be wrapped in a “uglifyOptions” object now: https://github.com/webpack-contrib/uglifyjs-webpack-plugin#uglifyoptions (as seen by https://github.com/JeffreyWay/laravel-mix/pull/1301/files).

This still doesn’t change the fact that I’m getting an exception originating from vendor.js on page load.

3reactions
ankurk91commented, Nov 10, 2017

uglify options was changed in version 1.6

https://github.com/JeffreyWay/laravel-mix/pull/1301/files#diff-9d9a6cd82f41984872a66a3ab0d440c4R256

New syntax should be

mix.options({
uglify: {
    uglifyOptions:{
        compress:{
        }
    }
}
});

Laravel mix already comes with some default options so you not need to override them - https://github.com/JeffreyWay/laravel-mix/blob/03ae69849ac6c7454e299f964a9f977eab7e36c8/src/config.js#L276-L287

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error npm run production - Laracasts
Wehn running npm production get error like bellow: Copy Code [hrace009@ko2svr hrace009.com]$ npm run prod > @ prod /var/www/hrace009.com > npm run ......
Read more >
npm run production error I can't decipher - Stack Overflow
That happened to me before. The fix that worked for me was to update the paths in package.json. cross-env must have updated its...
Read more >
Solved: I am getting npm run prod error while building a p...
I am getting npm run prod error while building a project, can someone help me to solve this?
Read more >
Error when 'npm run production' · Issue #836 · laravel-mix ...
It may be that some locked dependencies haven't updated properly. Try to delete node_modules folder and then do simple stupid npm install. I...
Read more >
DigitalOcean App, Laravel, npm run production fails
Are there any fixes to npm run prod fails on build? I would like to add this to ensure what is on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found