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 with scripts method

See original GitHub issue
  • Laravel Mix Version : 0.10.0
  • Node Version : 7.8.0
  • NPM Version : 4.2.0
  • OS : MacOS Sierra 10.12.4

Description:

I have an error since I tried to run the command npm run prod before pushing a project in production. This error does not occurs when I run npm run dev or npm run watch. I noticed (by commenting other portions of code into my webpack.mix.js file) that it seems that the mix.scriptsmethod causes the problem.

Anyway, here is my package.json content :

{
  "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": "^4.0.0",
    "laravel-mix": "0.*",
    "lodash": "^4.17.4"
  }
}

Here is my webpack.mix.js content that cause the error (everything else is commented) :

const { mix } = require('laravel-mix');

mix.scripts([
  'resources/assets/js/front/app.front.js'
], 'public/js/app.front.js');

Here is the console message when I run npm run prod :

> @ prod /Users/arthurlorent/workspace/genius
> npm run production


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

 95% emitting

 DONE  Compiled successfully in 112ms                                                                                                                                        18:00:46


undefined:92
    throw new DefaultsError(msg, defs);
    ^
Error:

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/Cellar/node/7.8.0/bin/node" "/usr/local/bin/npm" "run" "production"
npm ERR! node v7.8.0
npm ERR! npm  v4.2.0
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 '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! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     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! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/arthurlorent/.npm/_logs/2017-04-06T16_00_46_850Z-debug.log

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/Cellar/node/7.8.0/bin/node" "/usr/local/bin/npm" "run" "prod"
npm ERR! node v7.8.0
npm ERR! npm  v4.2.0
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 run production'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run production
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/arthurlorent/.npm/_logs/2017-04-06T16_00_46_882Z-debug.log

And finally, here is the content of the npm log :

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/7.8.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'prod' ]
2 info using npm@4.2.0
3 info using node@v7.8.0
4 verbose run-script [ 'preprod', 'prod', 'postprod' ]
5 info lifecycle @~preprod: @
6 silly lifecycle @~preprod: no script for preprod, continuing
7 info lifecycle @~prod: @
8 verbose lifecycle @~prod: unsafe-perm in lifecycle true
9 verbose lifecycle @~prod: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/arthurlorent/workspace/genius/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/arthurlorent/.composer/vendor/bin:/Users/arthurlorent/~/.npm-global/bin:/Users/arthurlorent/.composer/vendor/bin:/Users/arthurlorent/workspace/genius/~/.npm-global/bin:/Users/arthurlorent/.composer/vendor/bin:
10 verbose lifecycle @~prod: CWD: /Users/arthurlorent/workspace/genius
11 silly lifecycle @~prod: Args: [ '-c', 'npm run production' ]
12 silly lifecycle @~prod: Returned: code: 1  signal: null
13 info lifecycle @~prod: Failed to exec prod script
14 verbose stack Error: @ prod: `npm run production`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:194:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:194:7)
14 verbose stack     at maybeClose (internal/child_process.js:899:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid @
16 verbose cwd /Users/arthurlorent/workspace/genius
17 error Darwin 16.4.0
18 error argv "/usr/local/Cellar/node/7.8.0/bin/node" "/usr/local/bin/npm" "run" "prod"
19 error node v7.8.0
20 error npm  v4.2.0
21 error code ELIFECYCLE
22 error errno 1
23 error @ prod: `npm run production`
23 error Exit status 1
24 error Failed at the @ prod script 'npm run production'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the  package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error     npm run production
24 error You can get information on how to open an issue for this project with:
24 error     npm bugs
24 error Or if that isn't available, you can get their info via:
24 error     npm owner ls
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]

Steps To Reproduce:

Just run npm run prod to reproduce the problem explained above.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
evertramoscommented, May 30, 2017

@JeffreyWay on Laravel-Mix we should be using uglify-es as of: https://github.com/mishoo/UglifyJS2/tree/harmony

1reaction
Okipacommented, Apr 8, 2017

I found the error. I was installing the last laravel-mix and cross-env dependencies versions. It seems that this is what caused the error. I installed the versions provided by the last stable Laravel version and everything is OK now : https://github.com/laravel/laravel/blob/v5.4.16/package.json

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm run prod error with scripts method · Issue #675 - GitHub
I have an error since I tried to run the command npm run prod before pushing a project in production. This error does...
Read more >
Laravel mix error when running npm run prod script in ...
I just finished working with my project and want to deploy it in a production server which is a cloud hosting. When I...
Read more >
npm run prod ; returns error - Laracasts
hello, I try in production env to run npm run prod but I get this error message : > npm run production ......
Read more >
npm-run-script
Description. This runs an arbitrary command from a package's "scripts" object. If no "command" is provided, it will list the available scripts.
Read more >
[Solved] npm err! missing script: start - ItsJavaScript
The npm err! missing script: start mainly occurs if you have not specified the entry path in package.json to run the application.
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