Build command failed with exit code 1

I have build errors which i didn’t have before in previous deploys, although my webpack config hasn’t changed. Also my previous deploys cause error when I test them on a new test site.

12:11:30 PM: Build ready to start
12:11:56 PM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
12:11:56 PM: build-image tag: v4.10.1
12:11:56 PM: buildbot version: 1c362ef848ac5e35535bdb572ebca893db28c8a0
12:11:56 PM: Fetching cached dependencies
12:11:56 PM: Failed to fetch cache, continuing with build
12:11:56 PM: Starting to prepare the repo for build
12:11:56 PM: No cached dependencies found. Cloning fresh repo
12:11:56 PM: git clone https://github.com/alexkaze/movie-geek
12:11:57 PM: Preparing Git Reference refs/heads/master
12:11:57 PM: Parsing package.json dependencies
12:11:58 PM: Starting build script
12:11:58 PM: Installing dependencies
12:11:58 PM: Python version set to 2.7
12:11:59 PM: Downloading and installing node v16.17.1...
12:11:59 PM: Downloading https://nodejs.org/dist/v16.17.1/node-v16.17.1-linux-x64.tar.xz...
12:11:59 PM: Computing checksum with sha256sum
12:11:59 PM: Checksums matched!
12:12:01 PM: Now using node v16.17.1 (npm v8.15.0)
12:12:01 PM: Started restoring cached build plugins
12:12:01 PM: Finished restoring cached build plugins
12:12:02 PM: Attempting ruby version 2.7.2, read from environment
12:12:02 PM: Using ruby version 2.7.2
12:12:02 PM: Using PHP version 8.0
12:12:03 PM: No npm workspaces detected
12:12:03 PM: Started restoring cached node modules
12:12:03 PM: Finished restoring cached node modules
12:12:03 PM: Installing NPM modules using NPM version 8.15.0
12:12:03 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
12:12:03 PM: npm WARN config location in the cache, and they are managed by
12:12:03 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
12:12:03 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
12:12:03 PM: npm WARN config location in the cache, and they are managed by
12:12:03 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
12:12:06 PM: npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
12:12:07 PM: npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
12:12:07 PM: npm WARN deprecated har-validator@5.1.5: this library is no longer supported
12:12:11 PM: added 833 packages, and audited 834 packages in 8s
12:12:11 PM: 90 packages are looking for funding
12:12:11 PM:   run `npm fund` for details
12:12:11 PM: 3 high severity vulnerabilities
12:12:11 PM: To address all issues, run:
12:12:11 PM:   npm audit fix
12:12:11 PM: Run `npm audit` for details.
12:12:11 PM: NPM modules installed
12:12:11 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
12:12:11 PM: npm WARN config location in the cache, and they are managed by
12:12:11 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
12:12:11 PM: Started restoring cached go cache
12:12:11 PM: Finished restoring cached go cache
12:12:11 PM: Installing Go version 1.16.5 (requested 1.16.5)
12:12:16 PM: unset GOOS;
12:12:16 PM: unset GOARCH;
12:12:16 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64';
12:12:16 PM: export PATH="/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64/bin:${PATH}";
12:12:16 PM: go version >&2;
12:12:16 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.16.5.linux.amd64.env"
12:12:16 PM: go version go1.16.5 linux/amd64
12:12:16 PM: Installing missing commands
12:12:16 PM: Verify run directory
12:12:17 PM: ​
12:12:17 PM: ────────────────────────────────────────────────────────────────
12:12:17 PM:   Netlify Build                                                 
12:12:17 PM: ────────────────────────────────────────────────────────────────
12:12:17 PM: ​
12:12:17 PM: ❯ Version
12:12:17 PM:   @netlify/build 27.18.4
12:12:17 PM: ​
12:12:17 PM: ❯ Flags
12:12:17 PM:   baseRelDir: true
12:12:17 PM:   buildId: 63340fc279f7e865b281fe0a
12:12:17 PM:   deployId: 63340fc279f7e865b281fe0c
12:12:17 PM: ​
12:12:17 PM: ❯ Current directory
12:12:17 PM:   /opt/build/repo
12:12:17 PM: ​
12:12:17 PM: ❯ Config file
12:12:17 PM:   No config file was defined: using default values.
12:12:17 PM: ​
12:12:17 PM: ❯ Context
12:12:17 PM:   production
12:12:17 PM: ​
12:12:17 PM: ────────────────────────────────────────────────────────────────
12:12:17 PM:   1. Build command from Netlify app                             
12:12:17 PM: ────────────────────────────────────────────────────────────────
12:12:17 PM: ​
12:12:17 PM: $ npm run build-prod
12:12:17 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
12:12:17 PM: npm WARN config location in the cache, and they are managed by
12:12:17 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
12:12:17 PM: > movie-geek@1.0.0 build-prod
12:12:17 PM: > cross-env MODE=production webpack --mode=production
12:12:21 PM: node:internal/process/promises:279
12:12:21 PM:             triggerUncaughtException(err, true /* fromPromise */);
12:12:21 PM:             ^
12:12:21 PM: [RangeError: WebAssembly.instantiate(): Out of memory: wasm memory]
12:12:21 PM: ​
12:12:21 PM: ────────────────────────────────────────────────────────────────
12:12:21 PM:   "build.command" failed                                        
12:12:21 PM: ────────────────────────────────────────────────────────────────
12:12:21 PM: ​
12:12:21 PM:   Error message
12:12:21 PM:   Command failed with exit code 1: npm run build-prod (https://ntl.fyi/exit-code-1)
12:12:21 PM: ​
12:12:21 PM:   Error location
12:12:21 PM:   In Build command from Netlify app:
12:12:21 PM:   npm run build-prod
12:12:21 PM: ​
12:12:21 PM:   Resolved config
12:12:21 PM:   build:
12:12:21 PM:     command: npm run build-prod
12:12:21 PM:     commandOrigin: ui
12:12:21 PM:     publish: /opt/build/repo/dist
12:12:21 PM:     publishOrigin: ui
12:12:21 PM: Caching artifacts
12:12:21 PM: Started saving node modules
12:12:21 PM: Finished saving node modules
12:12:21 PM: Started saving build plugins
12:12:21 PM: Finished saving build plugins
12:12:21 PM: Started saving pip cache
12:12:21 PM: Finished saving pip cache
12:12:21 PM: Started saving emacs cask dependencies
12:12:21 PM: Finished saving emacs cask dependencies
12:12:21 PM: Started saving maven dependencies
12:12:21 PM: Finished saving maven dependencies
12:12:21 PM: Started saving boot dependencies
12:12:21 PM: Finished saving boot dependencies
12:12:21 PM: Started saving rust rustup cache
12:12:21 PM: Finished saving rust rustup cache
12:12:21 PM: Started saving go dependencies
12:12:21 PM: Finished saving go dependencies
12:12:21 PM: Error: ENOENT: no such file or directory, lstat '/opt/build/repo/node_modules'
12:12:21 PM:     at Object.realpathSync (node:fs:2538:7)
12:12:21 PM:     at getRealPath (/opt/build/repo/node_modules/fork-ts-checker-webpack-plugin/lib/typescript/worker/lib/file-system/real-file-system.js:122:93)
12:12:21 PM:     at Object.realPath (/opt/build/repo/node_modules/fork-ts-checker-webpack-plugin/lib/typescript/worker/lib/file-system/real-file-system.js:47:16)
12:12:21 PM:     at Object.readStats (/opt/build/repo/node_modules/fork-ts-checker-webpack-plugin/lib/typescript/worker/lib/file-system/passive-file-system.js:19:60)
12:12:21 PM:     at Object.directoryExists (/opt/build/repo/node_modules/fork-ts-checker-webpack-plugin/lib/typescript/worker/lib/system.js:61:54)
12:12:21 PM:     at Object.directoryProbablyExists (/opt/build/repo/node_modules/typescript/lib/typescript.js:19109:46)
12:12:21 PM:     at getPackageJsonInfo (/opt/build/repo/node_modules/typescript/lib/typescript.js:42973:34)
12:12:21 PM:     at loadModuleFromSpecificNodeModulesDirectory (/opt/build/repo/node_modules/typescript/lib/typescript.js:43354:27)
12:12:21 PM:     at loadModuleFromImmediateNodeModulesDirectory (/opt/build/repo/node_modules/typescript/lib/typescript.js:43335:58)
12:12:21 PM:     at /opt/build/repo/node_modules/typescript/lib/typescript.js:43325:39 {
12:12:21 PM:   errno: -2,
12:12:21 PM:   syscall: 'lstat',
12:12:21 PM:   code: 'ENOENT',
12:12:21 PM:   path: '/opt/build/repo/node_modules'
12:12:21 PM: }
12:12:21 PM: Error: write EPIPE
12:12:21 PM:     at process.target._send (node:internal/child_process:867:20)
12:12:21 PM:     at process.target.send (node:internal/child_process:740:19)
12:12:21 PM:     at /opt/build/repo/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/expose-rpc.js:27:31
12:12:21 PM:     at new Promise (<anonymous>)
12:12:21 PM:     at sendMessage (/opt/build/repo/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/expose-rpc.js:19:38)
12:12:21 PM:     at /opt/build/repo/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/expose-rpc.js:53:27
12:12:21 PM:     at Generator.throw (<anonymous>)
12:12:21 PM:     at rejected (/opt/build/repo/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/expose-rpc.js:6:65)
12:12:21 PM:     at processTicksAndRejections (node:internal/process/task_queues:96:5) {
12:12:21 PM:   errno: -32,
12:12:21 PM:   code: 'EPIPE',
12:12:21 PM:   syscall: 'write'
12:12:21 PM: }
12:12:22 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:12:22 PM: Creating deploy upload records
12:12:22 PM: Failing build: Failed to build site
12:12:23 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
12:12:23 PM: Finished processing build request in 27.146043212s

I’m not sure what you’re doing, but that appears like whatever you’re trying to do is needing more memory than there’s available. I can see that, that build was allocated 8 GB memory, however it seems to have happened so quickly, because the memory usage did not even get logged in our systems:

That’s a span of 7 seconds and it still shows just 1 dot.

I have forgotten to leave a link to my site https://mv-geek.netlify.app/

The project is based on Webpack and deployed from GitHub repo. I think you as a support engineer can look at the deploys history of this site.

Before September every new commit was deployed without any problems. Then I have noticed that my last deploy fails. Webpack config wasn’t significantly changed in the last commit so I have no idea why it fails now.

I have tried to create a new site where the second to last commit is deployed. This commit was ok before September. But it fails as well now. In other words, even the commit which was deployed well before fails now. I can’t find the reasons for it.

Perhaps because your dependencies or versions have changed? If you’d like to link us to a working build’s logs and a failed one’s logs (on the same site), we’ll be happy to try to help you figure out what changed between them.

I will be happy if you help me. What should I do?

Hi @Alex_K

As @fool says above, can you provide a link to

  • one deploy log where the build failed; and
  • one deploy log where the build succeeded.

Seccessful deploy: Netlify App
Failed deploy: Netlify App

Hello @Alex_K

After reviewing the two builds you provided and some others within your build history, I can see several version changes occurring. While there may not be any intended changes, unless you fix the version specifically to your build, a newer version could be loaded at build time.

This one uses node version v16.16.0 while this one uses v16.17.1

On the surface, this appears to be a OOM error occurring. To help remove any unknown variables, I would suggest you explicitly configure the version you need for your site.

This can be done as follows:

Sorry for the late reply.

I’ve found the problem. It’s my total stupidity. I don’t know why node variable was named as MODE. Obviously it must be NODE_ENV. I’ve fixed it in the last deploy and now the site works fine.

Thank you!

1 Like

Thanks for coming back and letting us know! Glad everything is working now :rocket:

I’ve jumped to conclusions…

I wrote above that the node variable name MODE was the problem. But it turned out it is not, the deploy was still failing. And now I really understand the problem. My webpack config has ImageMinimizerPlugin for image optimization. At the beginning it was configured with the squoosh library (@squoosh/lib). I decided to test new deploy without any image optimization at all and it was successful. I assumed the @squoosh/lib was the main problem (i.e it demands too mush memory that causes OOM error). As I still need image optimization in the project I tried to replace @squoosh/lib by imagemin library and it worked. Now the config is deployed without errors.

Thank you!