Command failed with exit code 7: npm rebuild && gatsby build

Hi, my site builds fine in my dev environment, but it keeps failing in Netlify. The problem started with a simple file upload, so I don’t think it’s related to any of the site content itself, I think it’s something to do with the environment. Can someone please point me in the right direction on how to solve this?

  • netlify site name: stupefied-brahmagupta-0baf00
  • FULL build log puts my post over the character limit and I’m limited to one screenshot, so did my best to capture both items here:

hi there, what version of the gatsby cli are you using?

This Support Guide contains a ton of useful debugging tips that can likely help you solve your problem :slight_smile:

If you are still having problems, please provide as much information as you can on what you have already tried, what your build settings are, your package.json, etc. Thanks!

Hi perry, my cloud IDE is in maintenance mode right now so I can’t get the exact gatsby-cli version #, but I ran an npm to upgrade to the latest version before trying the last build. I went through the support guide, but none of those suggestions seem to address my issue. I’m using the same build command that I have in Netlify build settings, no “command not found” in my build log, the file in the deploy that failed is < 20 MB, etc… I have many successful builds for this site before yesterday (9/14/2020), so the items related to missing packages and package.json don’t seem relevant. I attached a screenshot of my build settings to the original post. Here’s my package.json:

Blockquote
{
“name”: “gatsby-gitbook-boilerplate”,
“private”: true,
“description”: “Documentation, built with mdx”,
“author”: “Praveen praveen@hasura.io (@praveenweb)”,
“version”: “0.0.1”,
“dependencies”: {
“babel/plugin-proposal-export-default-from”: “^7.5.2”,
“emotion/core”: “^10.0.15”,
“emotion/styled-base”: “^10.0.15”,
“mdx-js/loader”: “^1.3.0”,
“mdx-js/mdx”: “^1.3.0”,
“mdx-js/react”: “^1.3.0”,
“playlyfe/gql”: “^2.6.1”,
“dotenv”: “^8.0.0”,
“emotion”: “^10.0.14”,
“emotion-server”: “^10.0.14”,
“emotion-theming”: “^10.0.14”,
“gatsby”: “^2.13.62”,
“gatsby-link”: “^2.2.5”,
“gatsby-plugin-emotion”: “^4.1.2”,
“gatsby-plugin-gtag”: “^1.0.11”,
“gatsby-plugin-layout”: “^1.1.3”,
“gatsby-plugin-mdx”: “^1.0.24”,
“gatsby-plugin-netlify-cms”: “^4.1.7”,
“gatsby-plugin-react-helmet”: “^3.1.3”,
“gatsby-plugin-sharp”: “^2.2.11”,
“gatsby-plugin-sitemap”: “^2.2.6”,
“gatsby-remark-copy-linked-files”: “^2.1.5”,
“gatsby-remark-images”: “^3.1.11”,
“gatsby-source-filesystem”: “^2.1.9”,
“gatsby-transformer-remark”: “^2.6.14”,
“graphql”: “^14.4.2”,
“is-absolute-url”: “^3.0.0”,
“lodash.flatten”: “^4.4.0”,
“lodash.startcase”: “^4.4.0”,
“netlify-cms-app”: “^2.9.7”,
“react”: “^16.9.0”,
“react-dom”: “^16.9.0”,
“react-emotion”: “^9.1.3”,
“react-feather”: “^2.0.3”,
“react-github-btn”: “^1.0.6”,
“react-helmet”: “^5.2.1”,
“react-live”: “^2.1.2”,
“system-components”: “^3.0.3”
},
“license”: “MIT”,
“main”: “n/a”,
“scripts”: {
“start”: “gatsby develop”,
“build”: “gatsby build --prefix-paths”
},
“devDependencies”: {
“gatsby-plugin-remove-trailing-slashes”: “^2.1.2”,
“prism-react-renderer”: “^0.1.7”
}
}

I’m not able to post the entire build log here because I keep getting an error due to the number of characters, but here is the first piece of the log where something fails:

5:51:13 AM: evp_bytestokey@1.0.3 /opt/build/repo/node_modules/evp_bytestokey
5:51:19 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1

Here’s the version of Gatsby and Gatsby CLI that I’m using in my dev environment:

root@goorm:/workspace/learningsite(master)# gatsby -v
Gatsby CLI version: 2.12.97
Gatsby version: 2.23.11

@perry, here is a link to the full build log. Any clues in here about what I should try next? Thanks for your help with this! https://drive.google.com/file/d/16zEF1ZbExan953IzO-uz9GdrdkdhUM9a/view?usp=sharing

hey there, could you post your package.json please?

also worth suggesting you give this a read through if you haven’t already:

Hiya, sorry you are having trouble with your build.

This Support Guide contains a ton of useful debugging tips.

@perry, I posted my package.json and notes about the support guide on 9/15. Are you able to see my comment? Here it is again, just in case:

I went through the support guide, but none of those suggestions seem to address my issue. I’m using the same build command that I have in Netlify build settings, no “command not found” in my build log, the file in the deploy that failed is < 20 MB, etc… I have many successful builds for this site before yesterday (9/14/2020), so the items related to missing packages and package.json don’t seem relevant. I attached a screenshot of my build settings to the original post. Here’s my package.json:

{
“name”: “gatsby-gitbook-boilerplate”,
“private”: true,
“description”: “Documentation, built with mdx”,
“author”: “Praveen praveen@hasura.io (@praveenweb)”,
“version”: “0.0.1”,
“dependencies”: {
“babel/plugin-proposal-export-default-from”: “^7.5.2”,
“emotion/core”: “^10.0.15”,
“emotion/styled-base”: “^10.0.15”,
“mdx-js/loader”: “^1.3.0”,
“mdx-js/mdx”: “^1.3.0”,
“mdx-js/react”: “^1.3.0”,
“playlyfe/gql”: “^2.6.1”,
“dotenv”: “^8.0.0”,
“emotion”: “^10.0.14”,
“emotion-server”: “^10.0.14”,
“emotion-theming”: “^10.0.14”,
“gatsby”: “^2.13.62”,
“gatsby-link”: “^2.2.5”,
“gatsby-plugin-emotion”: “^4.1.2”,
“gatsby-plugin-gtag”: “^1.0.11”,
“gatsby-plugin-layout”: “^1.1.3”,
“gatsby-plugin-mdx”: “^1.0.24”,
“gatsby-plugin-netlify-cms”: “^4.1.7”,
“gatsby-plugin-react-helmet”: “^3.1.3”,
“gatsby-plugin-sharp”: “^2.2.11”,
“gatsby-plugin-sitemap”: “^2.2.6”,
“gatsby-remark-copy-linked-files”: “^2.1.5”,
“gatsby-remark-images”: “^3.1.11”,
“gatsby-source-filesystem”: “^2.1.9”,
“gatsby-transformer-remark”: “^2.6.14”,
“graphql”: “^14.4.2”,
“is-absolute-url”: “^3.0.0”,
“lodash.flatten”: “^4.4.0”,
“lodash.startcase”: “^4.4.0”,
“netlify-cms-app”: “^2.9.7”,
“react”: “^16.9.0”,
“react-dom”: “^16.9.0”,
“react-emotion”: “^9.1.3”,
“react-feather”: “^2.0.3”,
“react-github-btn”: “^1.0.6”,
“react-helmet”: “^5.2.1”,
“react-live”: “^2.1.2”,
“system-components”: “^3.0.3”
},
“license”: “MIT”,
“main”: “n/a”,
“scripts”: {
“start”: “gatsby develop”,
“build”: “gatsby build --prefix-paths”
},
“devDependencies”: {
“gatsby-plugin-remove-trailing-slashes”: “^2.1.2”,
“prism-react-renderer”: “^0.1.7”
}
}

Hi, @ranjeet.singh, when building at Netlify it is important to configure the build to match your local build environment. There are numerous ways this can be done (because there are numerous ways to build sites at Netlify).

One of the most common ways this is done is with environment variables, more on that below:

Does the configuration at Netlify match your local system?

For example, I see the node version used in the failing builds is 8.11.3. From the logs:

1:01:03 PM: Downloading and installing node v8.11.3...

As Gatsby itself requires version 10.13.0 or newer, my best guess is that this is not the version of node being used locally. On the other hand, I see this has been set to 8.11.3 manually already.

Would you please confirm the node version used locally and double check that the node version with the environment variable NODE_VERSION at Netlify matches?

If that doesn’t resolve the issue, please let us know.

Thanks @luke! That was the problem. I went to Site Settings / Build & deploy / Environment (/settings/deploys#environment) and saw that there was a set value for NODE_VERSION. I removed that variable and now the site deploys perfectly.

1 Like