"build.command" failed when deploying app (exit code 127, exit code 2)

Hello -

I’m trying to deploy a Vue.js site to Netlify, but it is failing at the Build step.
The Netlify site name is: https://travel-bug-vue-app.netlify.app

It looks like Netlify is unable to run this command successfully: “CI= npm run build”

However, when I run npm run build locally, it works fine.

Here is the attached error message:
9:23:01 PM: Netlify Build
9:23:01 PM: ────────────────────────────────────────────────────────────────
9:23:01 PM: ​
9:23:01 PM: ❯ Version
9:23:01 PM: @netlify/build 29.54.0
9:23:01 PM: ​
9:23:01 PM: ❯ Flags
9:23:01 PM: accountId: 60cd1045d668d87521045187
9:23:01 PM: baseRelDir: true
9:23:01 PM: buildId: 66de5be437850600081f7425
9:23:01 PM: deployId: 66de5be437850600081f7427
9:23:01 PM: ​
9:23:01 PM: ❯ Current directory
9:23:01 PM: /opt/build/repo
9:23:01 PM: ​
9:23:01 PM: ❯ Config file
9:23:01 PM: No config file was defined: using default values.
9:23:01 PM: ​
9:23:01 PM: ❯ Context
9:23:01 PM: production
9:23:01 PM: ​
9:23:01 PM: Build command from Netlify app
9:23:01 PM: ────────────────────────────────────────────────────────────────
9:23:01 PM: ​
9:23:01 PM: $ CI= npm run build
9:23:01 PM: > travel-bug-vue-app@0.1.0 build
9:23:01 PM: > vue-cli-service build
9:23:01 PM: sh: 1: vue-cli-service: not found
9:23:01 PM: ​
9:23:01 PM: “build.command” failed
9:23:01 PM: ────────────────────────────────────────────────────────────────
9:23:01 PM: ​
9:23:01 PM: Error message
9:23:01 PM: Command failed with exit code 127: CI= npm run build (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)
9:23:01 PM: ​
9:23:01 PM: Error location
9:23:01 PM: In Build command from Netlify app:
9:23:01 PM: CI= npm run build
9:23:01 PM: ​
9:23:01 PM: Resolved config
9:23:01 PM: build:
9:23:01 PM: command: CI= npm run build
9:23:01 PM: commandOrigin: ui
9:23:01 PM: environment:
9:23:01 PM: - NODE_ENV
9:23:01 PM: - VUE_APP_MAPBOX_API_KEY
9:23:01 PM: publish: /opt/build/repo/dist
9:23:01 PM: publishOrigin: ui
9:23:02 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
9:23:02 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:23:02 PM: Failing build: Failed to build site
9:23:02 PM: Finished processing build request in 22.072s

Here are the build settings:
Runtime: Not set
Base directory: /
Package directory: Not set
Build command: CI= npm run build
Publish directory: dist
Functions directory: netlify/functions
Deploy log visibility: Logs are public
Build status: Active

I’ve reviewed several other threads on the forums, and Googled the error message, but haven’t been able to resolve the issue. I’ve also experimented with

  • updating the build command on Netlify
  • reinstalling @vue/cli-service
  • adding @vue/cli-service as a dependency in package.json

The error message seems to suggest that there’s a problem with the build command. Does that mean the issue is somewhere within the package.json file? Specifically, the “build” script?

Would greatly appreciate any help/ideas for troubleshooting. Thank you.

@coder2 The actual error is:

If you check your screenshot you will see that vue-cli-service is in your devDependencies.

I’d imagine they haven’t been installed.

There is this note in the documentation regarding devDependencies:
https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-environment

I’m not sure if that’s your precise issue, but I’d investigate along those lines.

Hi Nathan,

Thanks for your response. I re-installed vue-cli-service locally, and also ensured it was present in both “dependencies” and “devDependencies” in my package.json file:
{
“name”: “travel-bug-vue-app”,
“version”: “0.1.0”,
“private”: true,
“scripts”: {
“start”: “node index.js”,
“serve”: “vue-cli-service serve”,
“build”: “vue-cli-service build”,
“lint”: “vue-cli-service lint”
},
“dependencies”: {
@vue/cli”: “^5.0.8”,
@vue/cli-plugin-babel”: “~4.5.0”,
@vue/cli-plugin-eslint”: “~4.5.0”,
@vue/cli-plugin-router”: “~4.5.0”,
@vue/cli-service”: “~4.5.0”,
@vue/eslint-config-prettier”: “^6.0.0”,
“axios”: “^0.21.1”,
“babel-eslint”: “^10.1.0”,
“core-js”: “^3.6.5”,
“eslint”: “^6.7.2”,
“eslint-plugin-prettier”: “^3.3.1”,
“eslint-plugin-vue”: “^6.2.2”,
“install”: “^0.13.0”,
“mapbox-gl”: “^2.2.0”,
“prettier”: “^2.2.1”,
“vue”: “^2.6.11”,
“vue-router”: “^3.2.0”,
“vue-template-compiler”: “^2.7.16”
},
“devDependencies”: {
@vue/cli”: “^5.0.8”,
@vue/cli-plugin-babel”: “~4.5.0”,
@vue/cli-plugin-eslint”: “~4.5.0”,
@vue/cli-plugin-router”: “~4.5.0”,
@vue/cli-service”: “~4.5.0”,
@vue/eslint-config-prettier”: “^6.0.0”,
“axios”: “^0.21.1”,
“babel-eslint”: “^10.1.0”,
“core-js”: “^3.6.5”,
“eslint”: “^6.7.2”,
“eslint-plugin-prettier”: “^3.3.1”,
“eslint-plugin-vue”: “^6.2.2”,
“install”: “^0.13.0”,
“mapbox-gl”: “^2.2.0”,
“prettier”: “^2.2.1”,
“vue”: “^2.6.11”,
“vue-router”: “^3.2.0”,
“vue-template-compiler”: “^2.7.16”
}
}

Unfortunately, Netlify still seems to be returning the same error message in the latest build:

Do you have any other ideas for debugging the issue?

I’ve previously looked at the following articles, but will scan through them again:

I’m going to try installing the netlify-cli in my terminal to try to mimic the failed build locally:

Ok, here’s an update:

By using the Netlify CLI (see URL in previous comment), I was able to deploy the app manually via my local terminal.

I ran these commands, and the deploy was successful:

netlify build
netlify deploy --prod

However, when I push an update to the repo on Github, the automated Netlify build that gets triggered still fails (see the 10:18pm deploy – 3rd one down on the list):

I’d still like to figure out the root cause of why the “automated” Netlify build still fails. It’d be awesome if the Netlify deploy could pass the “build” step without requiring manual intervention with the Netlify CLI.


Side note:
I looked at the env variables that Netlify is picking up by running netlify env:list in my terminal.
The NODE_ENV variable was set to “production”, in case that is relevant for troubleshooting:

It’s relevant to what I mentioned earlier:

It’s weird that you now have it in both your devDependencies and dependencies, have you tried with it only in your dependencies?

Yes – I’ve tried with the package in dependencies only (and not in devDependencies), and it still returned the same error message.

Hi, @coder2. The explanation is earlier in your deploy logs but you did not post the pertinent section. The explanation can be found here:

7:12:56 PM: Now using node v20.17.0 (npm v10.8.2)
7:12:56 PM: Enabling Node.js Corepack
7:12:56 PM: Started restoring cached build plugins
7:12:56 PM: Finished restoring cached build plugins
7:12:56 PM: WARNING: The environment variable 'NODE_ENV' is set to 'production'. Any 'devDependencies' in package.json will not be installed
7:12:56 PM: Started restoring cached corepack dependencies
7:12:56 PM: Finished restoring cached corepack dependencies
7:12:56 PM: No npm workspaces detected
7:12:56 PM: Started restoring cached node modules
7:12:56 PM: Finished restoring cached node modules
7:12:56 PM: Installing npm packages using npm version 10.8.2
7:12:57 PM: npm warn EBADENGINE Unsupported engine {
7:12:57 PM: npm warn EBADENGINE   package: '@achrinza/node-ipc@9.2.2',
7:12:57 PM: npm warn EBADENGINE   required: { node: '8 || 10 || 12 || 14 || 16 || 17' },
7:12:57 PM: npm warn EBADENGINE   current: { node: 'v20.17.0', npm: '10.8.2' }
7:12:57 PM: npm warn EBADENGINE }
7:12:57 PM: npm warn EBADENGINE Unsupported engine {
7:12:57 PM: npm warn EBADENGINE   package: '@achrinza/node-ipc@9.2.2',
7:12:57 PM: npm warn EBADENGINE   required: { node: '8 || 10 || 12 || 14 || 16 || 17' },
7:12:57 PM: npm warn EBADENGINE   current: { node: 'v20.17.0', npm: '10.8.2' }
7:12:57 PM: npm warn EBADENGINE }
7:12:57 PM: npm warn EBADENGINE Unsupported engine {
7:12:57 PM: npm warn EBADENGINE   package: '@achrinza/node-ipc@9.2.2',
7:12:57 PM: npm warn EBADENGINE   required: { node: '8 || 10 || 12 || 14 || 16 || 17' },
7:12:57 PM: npm warn EBADENGINE   current: { node: 'v20.17.0', npm: '10.8.2' }
7:12:57 PM: npm warn EBADENGINE }
7:12:57 PM: npm warn EBADENGINE Unsupported engine {
7:12:57 PM: npm warn EBADENGINE   package: '@achrinza/node-ipc@9.2.2',
7:12:57 PM: npm warn EBADENGINE   required: { node: '8 || 10 || 12 || 14 || 16 || 17' },
7:12:57 PM: npm warn EBADENGINE   current: { node: 'v20.17.0', npm: '10.8.2' }
7:12:57 PM: npm warn EBADENGINE }

There are dependency install failures occurring because the version of node your build uses is incompatible with the packages you are trying to install.

You will need to fix these errors to resolve the issue.

@coder2 Based on what has been provided by @luke it looks like node 17 is the newest version it supports.

The appropriate documentation (for setting the node.js version) can be found here: