Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sandersjj's avatar

npm run production Fails.

Hi,

I am having this config in 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 --display-error-details --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": {
    "laravel-mix": "^2.0",
    "less": "^3.0.2",
    "less-loader": "^4.1.0",
    "lodash": "^4.17.4",
    "popper.js": "^1.12",
    "tailwindcss": "^0.5.2",
    "vue": "^2.5.7",
    "yarn": "*"
  },
  "dependencies": {
    "tinymce": "^4.6.4",
    "axios": "^0.18",
    "cross-env": "^5.1"
  }
}

However, when I run: npm i -- production and npm run production I get the following error:

0 info it worked if it ends with ok
1 warn npm npm does not support Node.js v7.5.0
2 warn npm You should probably upgrade to a newer version of node as we
3 warn npm can't make any promises that npm will work with this version.
4 warn npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11.
5 warn npm You can find the latest version at https://nodejs.org/
6 verbose cli [ '/usr/local/Cellar/node/7.5.0/bin/node',
6 verbose cli   '/usr/local/bin/npm',
6 verbose cli   'run',
6 verbose cli   'production' ]
7 info using [email protected]
8 info using [email protected]
9 verbose run-script [ 'preproduction', 'production', 'postproduction' ]
10 info lifecycle @~preproduction: @
11 info lifecycle @~production: @
12 verbose lifecycle @~production: unsafe-perm in lifecycle true
13 verbose lifecycle @~production: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Volumes/DEV-DRIVE/hypotheekbond/test/jigal/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/jigal.sanders/Library/Android/sdk/tools:/Users/jigal.sanders/Library/Android/sdk/platform-tools
14 verbose lifecycle @~production: CWD: /Volumes/DEV-DRIVE/hypotheekbond/test/jigal
15 silly lifecycle @~production: Args: [ '-c',
15 silly lifecycle   'cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js' ]
16 silly lifecycle @~production: Returned: code: 1  signal: null
17 info lifecycle @~production: Failed to exec production script
18 verbose stack Error: @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
18 verbose stack Exit status 1
18 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:304:16)
18 verbose stack     at emitTwo (events.js:106:13)
18 verbose stack     at EventEmitter.emit (events.js:192:7)
18 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
18 verbose stack     at emitTwo (events.js:106:13)
18 verbose stack     at ChildProcess.emit (events.js:192:7)
18 verbose stack     at maybeClose (internal/child_process.js:890:16)
18 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
19 verbose pkgid @
20 verbose cwd /Volumes/DEV-DRIVE/hypotheekbond/test/jigal
21 verbose Darwin 17.5.0
22 verbose argv "/usr/local/Cellar/node/7.5.0/bin/node" "/usr/local/bin/npm" "run" "production"
23 verbose node v7.5.0
24 verbose npm  v6.1.0
25 error code ELIFECYCLE
26 error errno 1
27 error @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
27 error Exit status 1
28 error Failed at the @ production script.
28 error This is probably not a problem with npm. There is likely additional logging output above.
29 verbose exit [ 1, true ]
0 likes
4 replies
topvillas's avatar

Read the error. It tells you what the problem is how to solve it at the start.

1 like
sandersjj's avatar

@topvillas thanks for your prompt. I thought that I already upgraded NPM and Node. But now I am getting this new error:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'production' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'preproduction', 'production', 'postproduction' ]
5 info lifecycle @~preproduction: @
6 info lifecycle @~production: @
7 verbose lifecycle @~production: unsafe-perm in lifecycle true
8 verbose lifecycle @~production: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Volumes/DEV-DRIVE/hypotheekbond/test/jigal/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/jigal.sanders/Library/Android/sdk/tools:/Users/jigal.sanders/Library/Android/sdk/platform-tools
9 verbose lifecycle @~production: CWD: /Volumes/DEV-DRIVE/hypotheekbond/test/jigal
10 silly lifecycle @~production: Args: [ '-c',
10 silly lifecycle   'cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js' ]
11 silly lifecycle @~production: Returned: code: 1  signal: null
12 info lifecycle @~production: Failed to exec production script
13 verbose stack Error: @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:304:16)
13 verbose stack     at EventEmitter.emit (events.js:182:13)
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 ChildProcess.emit (events.js:182:13)
13 verbose stack     at maybeClose (internal/child_process.js:961:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
14 verbose pkgid @
15 verbose cwd /Volumes/DEV-DRIVE/hypotheekbond/test/jigal
16 verbose Darwin 17.5.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "production"
18 verbose node v10.3.0
19 verbose npm  v6.1.0
20 error code ELIFECYCLE
21 error errno 1
22 error @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
22 error Exit status 1
23 error Failed at the @ production script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Just not sure how to handle this. I guess it has to do with something wrong in my package.json but can't figure out what.

Cronix's avatar

I'd delete the node_modules dir and rerun npm install (or yarn if you're using that) and then try again.

Also remove anything from your package.json that you're not actually using.

1 like
ricardovigatti's avatar

I had this issue recently, maybe you are running out of memory. Check it out. In my case, was a problem with swap on Ubuntu, so I just restarted my server to get it working.

2 likes

Please or to participate in this conversation.