Error running command: Build script returned non-zero exit code: 127

It seems the build is failing when I try to deploy my site to netlify, judging from the logs it could be my parcel.js setup. The error in the logs are:

12:19:29 AM: Error running command: Build script returned non-zero exit code: 127
12:19:29 AM: Failing build: Failed to build site
12:19:29 AM: failed during stage 'building site': Build script returned non-zero exit code: 127
12:19:29 AM: Finished processing build request in 21.32707912s

My deploy setting on Netlify are:

Base directory: Not set
Build command: parcel build index.html
Publish directory: dist

Having searched for similar problems I thought it could be dependency issue, however, after using ‘Yarn’ to install dependencies I still get the same problem.

package.json

{
  "name": "ed",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "fullpage.js": "^3.0.5"
  },
  "devDependencies": {
    "cssnano": "^4.1.10"
  }
}

Below is the file structure, any help in troubleshooting this would be greatly appreciated.

enter image description here

I’d suggest using the workflow described here to debug:

…and if you can’t get things working, letting us know 2 things that will help us advise you:

  1. what you’ve tried to fix it and
  2. link to the logs in our UI so we can examine in more detail

The reason I don’t have more specific advice right now is that you’ve shown only the symptoms of the failure - and not the failure itself, which would be further up the logs or instead not discoverable even by us from the logs without knowing the deploy ID.

I was stuck with this same error yesterday. It seems that Netlify did not like seeing both package-lock.json and yarn.lock files. I’ve been using npm as my package manager, so I deleted yarn.lock and my builds started to work again.

I would also suggest deleting node_modules, package-lock.json, and doing a fresh npm install, just to be thorough.

3 Likes

these are super helpful suggestions, @stufinn!

2 Likes

Thanks! Removing the yarn.lock file also worked for me.

2 Likes

Just thought I’d chime in with my resolution for this error. The netlify.toml file command had “yarn run build” for the [build] command. Since I am using npm that’s obviously a problem. Replaced with “npm run build” and all is well.

1 Like

thanks for sharing your solution, @robinleboe! I bet you are not the only one!

1 Like

I just ran into this issue again and for what it’s worth, the reason I got the 127 error this time is because I didn’t properly specify the Base directory and Publish directory in my Netlify deploy settings.

2 Likes

I ran into this same problem. After reading this (and several other docs provided by the great problem solvers in this thread), I will share my solution here for any future React / MERN developers who run into this deployment issue.

I used the following steps to achieve resolution:

  1. delete the current package-lock.json, yarn.lock, and node_modules files/folders from working directory.
  2. use yarn install to create a fresh yarn.lock and node_modules (I am using the yarn tools, if you use npm you can substitute accordingly).
  3. double check that my repository uses yarn build in the Netlify build options (it is worth checking your scripts in package.json as well if you also use custom scripts – npm users will probably build with npm run-script build or something along those lines).
  4. git push and watch deployment log as Netlify’s awesome CI kicks in.

Make sure you don’t get confused with your build commands/scripts and doing a fresh install of your packages never hurts! You can always make a backup before hand or use git version control to restore back anything lost too.

Thanks,
Jay

3 Likes

thanks so much for sharing this straightforward writeup, @jaylowe1!

Great, that worked for me – thanks!

1 Like

Hi Perry,
would you be able to check the deployment error message of my site oppenberger.netlify.app.
Deployment fails with this error code
4:48:39 PM: Error running command: Build script returned non-zero exit code: 1

4:48:39 PM: Failing build: Failed to build site

4:48:39 PM: failed during stage ‘building site’: Build script returned non-zero exit code: 1

4:48:39 PM: Finished processing build request in 3m1.393768483s

but also show a massive code block that doesn’t tell me anything. I am not sure what breaks the deployment and what to look for.

my package.json
“dependencies”: {
@material-ui/core”: “^4.3.0”,
“babel-plugin-styled-components”: “^1.10.6”,
“bluebird”: “^3.5.5”,
“bootstrap”: “^4.3.1”,
“dompurify”: “^2.0.7”,
“gatsby”: “^2.20.8”,
“gatsby-image”: “^2.2.6”,
“gatsby-plugin-gtag”: “^1.0.11”,
“gatsby-plugin-manifest”: “^2.3.3”,
“gatsby-plugin-netlify”: “^2.1.3”,
“gatsby-plugin-offline”: “^2.2.4”,
“gatsby-plugin-prefetch-google-fonts”: “^1.4.2”,
“gatsby-plugin-react-helmet”: “^3.1.2”,
“gatsby-plugin-robots-txt”: “^1.5.0”,
“gatsby-plugin-sharp”: “^2.5.3”,
“gatsby-plugin-sitemap”: “^2.2.5”,
“gatsby-plugin-styled-components”: “^3.1.2”,
“gatsby-source-filesystem”: “^2.2.2”,
“gatsby-source-wordpress”: “^3.1.9”,
“gatsby-transformer-sharp”: “^2.4.3”,
“prop-types”: “^15.7.2”,
“react”: “^16.8.6”,
“react-dom”: “^16.8.6”,
“react-helmet”: “^5.2.1”,
“react-icons”: “^3.7.0”,
“react-jvectormap”: “0.0.16”,
“slash”: “^3.0.0”,
“styled-components”: “^4.3.2”
},
help, please!

can you post or link us to a failed deploy log please - i do have the power to be able to read it :mage:

the log is to long to post it in here so i hope this link works for you https://app.netlify.com/sites/oppenberger/deploys/5eb07ef09a9beb0174654cd2

hey oppenberger,

so i got a little ahead of myself - is your app building correctly on local? :thinking:

I did check the log, and I am 98% sure that the giant code block you are seeing is somehow related to jQuery. I am wondering if somehow you are maybe linking to or incorporating jquery in your app in way that isn’t quite by the book. I realize the logging isn’t as useful as it could be.
Which ssg are you using to build this?

so, my local build works just fine and I am not using any jquery code in this project. However, I did add an extra package called “react-jvectormap”: “0.0.16” which I believe is full jquery code maybe it’s the troublemaker.

I am using Gatsby as my ssg

ok cool, i would suggest removing the possibly problematic dependency from your package.json and see if you can get a working deploy without it, just so we can narrow it down to that package. if you figure it out please let us know.

If it works on local but not on our system, there are three main culprits:

a.) case sensitivity

b.) some minor version inconsistency. Next question here is - did you commit your package lock file taken from your local machine? I would recommend that you do (try clear cache and redeploy for a fresh install). For more details on why this can cause problems, check my writeup in this similar thread:

c.) something is being ignored on remote because you have a gitignore (this is kinda rare)

hi perry, I removed the react-jvectormap package and also the dompurify package (this one caused an additional error) and it deployed without error message. thank you for help.

1 Like

glad its working now. We have heard all kinds of difficulty from people using dompurify. If you run a search here in the forums you’ll see what i mean :face_with_head_bandage: