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

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.


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 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
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

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:

I am trying to use react-jvectormap (0.0.16) with Gatsby and deploy it on Netlify. But I’m getting build errors. Removing the package imports from code results in a successful build. The package works well on the local server though. Here are the logs,

Were you able to resolve the build error while keeping react-jvectormap? If so, can you please share what worked for you?

I have checked and can confirm there is no case-sensitivity issue in the code/imports. I also deleted the node_modules folder, reinstalled packages and pushed package.json and package-lock.json files. Also, clearing cache and redeploying didn’t work either.

Any help would be appreciated.

P.S. I’m not using dompurify

HI, unfortunately I did not solve the issue as of now and got busy with other things. Sorry for being no help here.

hi @mujeebahmed10p - Sorry you are encountering this! I am not exactly sure what to suggest that I haven’t already except to reach out to the folks who made the package and see if they have any ideas as to what could be causing the problem. If they give you any useful info please do let us know. I wish I had more ideas - but i’m stumped.

Thank you for the follow-up to share what you discovered, @mujeebahmed10p. Closing the loop to share what you learned will hopeful provide benefit to someone else searching the community site for answers in the future.

We appreciate that you took the time to share your experience. It is amazingly helpful and not everyone loops back here when they find a solution! :+1:

1 Like

Thanks for helping out guys! I really appreciate it.

Got a tip from someone to run,

gatsby serve

(on local machine) and lo and behold I got a different error,
WebpackError: TypeError: Cannot set property 'vectorMap' of undefined

The issue is definitely not related to Netlify. It’s just that Gatsby isn’t able to use that package in it’s build process (probably need to add something to gatsby-config.js before it will start working).

Thanks bro…i got my problem solved

I struggled for 3 hours until I found your solution. :heart:

Worked! Thanks @jaylowe1