dniccum's avatar

Laravel Mix 5.X production build error in Docker container

I am currently encountering an error during the production build process within a Docker container that I cannot explain. The logs are extremely ambiguous and don't' necessarily say what is going on. This is what I am seeing:

[webpack.Progress] 92% chunk asset optimization
[webpack.Progress] 92% chunk asset optimization TerserPlugin

npm ERR! code ELIFECYCLEnpm 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.

I have tested the development build process (yarn dev) and everything works just fine. I am having no issues on my local environment outside of the Docker container. I have also ran yarn upgrade and this has not had any affect.

Any help would be appreciated.

Version of Node

12.13

Version of Mix

5.0.4

Debug logs

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', '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 warn lifecycle The node binary used for scripts is /tmp/yarn--1620154751186-0.19642695221228879/node but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
8 verbose lifecycle @~production: unsafe-perm in lifecycle true
9 verbose lifecycle @~production: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/ops/node_modules/.bin:/tmp/yarn--1620154751186-0.19642695221228879:/ops/node_modules/.bin:/usr/local/share/.config/yarn/link/node_modules/.bin:/usr/local/libexec/lib/node_modules/npm/bin/node-gyp-bin:/usr/local/lib/node_modules/npm/bin/node-gyp-bin:/usr/local/bin/node_modules/npm/bin/node-gyp-bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
10 verbose lifecycle @~production: CWD: /ops
11 silly lifecycle @~production: Args: [
11 silly lifecycle   '-c',
11 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 ]
12 silly lifecycle @~production: Returned: code: 1  signal: null
13 info lifecycle @~production: Failed to exec production script
14 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`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
14 verbose stack     at EventEmitter.emit (events.js:210:5)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
14 verbose stack     at ChildProcess.emit (events.js:210:5)
14 verbose stack     at maybeClose (internal/child_process.js:1021:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
15 verbose pkgid @
16 verbose cwd /ops
17 verbose Linux 5.10.25-linuxkit
18 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "production"
19 verbose node v12.13.1
20 verbose npm  v6.12.1
21 error code ELIFECYCLE
22 error errno 1
23 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`
23 error Exit status 1
24 error Failed at the @ production script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]

0 likes
1 reply
danilo00010's avatar

Hi, i got a similiar problem and i tried reinstall cross-env but only when i reinstall laravel-mix it worked, so this is my advice.

Try to uninstall node and npm of WSL distro, uninstall laravel-mix from your project and then install it again.

Hope it helps, worked for me!

Please or to participate in this conversation.