Node v16.15.1 (npm v8.11.0) breaks some builds

Node v16.15.0 (npm v8.5.5) was updated to v16.15.1 (npm v8.11.0) on June 1, which broke about half of my deployed sites.

For others having this problem: To fix, either revert back to v16.15.0 or use npm flags. Set the env variable NPM_FLAGS to --legacy-peer-deps in Netlify’s dashboard, or set the variable NODE_VERSION to 16.15.0 in the dashboard or using a .nvmrc file.


Error log:

7:55:43 PM: Build ready to start
7:56:51 PM: build-image version: d2c6dbeac570350a387d832f64bc980dc964ad65 (focal)
7:56:51 PM: build-image tag: v4.8.0
7:56:51 PM: buildbot version: 4aaa27647e859c2d38cfbb25901ceae1e7f3eeae
7:56:51 PM: Fetching cached dependencies
7:57:02 PM: Finished downloading cache in 11.233987149s
7:57:02 PM: Starting to extract cache
7:57:35 PM: Finished extracting cache in 32.620340344s
7:57:35 PM: Finished fetching cache in 43.972713102s
7:57:35 PM: Starting to prepare the repo for build
7:57:35 PM: Preparing Git Reference refs/heads/main
7:57:36 PM: Parsing package.json dependencies
7:57:36 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'netlify/functions' versus '' in the Netlify UI
7:57:37 PM: Starting build script
7:57:37 PM: Installing dependencies
7:57:37 PM: Python version set to 2.7
7:57:37 PM: Started restoring cached node version
7:57:38 PM: Finished restoring cached node version
7:57:38 PM: Attempting node version 'v16' from .nvmrc
7:57:38 PM: Downloading and installing node v16.15.1...
7:57:39 PM: Downloading https://nodejs.org/dist/v16.15.1/node-v16.15.1-linux-x64.tar.xz...
7:57:39 PM: Computing checksum with sha256sum
7:57:39 PM: Checksums matched!
7:57:42 PM: Now using node v16.15.1 (npm v8.11.0)
7:57:42 PM: Started restoring cached build plugins
7:57:42 PM: Finished restoring cached build plugins
7:57:42 PM: Attempting ruby version 2.7.2, read from environment
7:57:43 PM: Using ruby version 2.7.2
7:57:44 PM: Using PHP version 8.0
7:57:44 PM: No npm workspaces detected
7:57:44 PM: Started restoring cached node modules
7:57:44 PM: Finished restoring cached node modules
7:57:45 PM: Installing NPM modules using NPM version 8.11.0
7:57:45 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
7:57:45 PM: npm WARN config location in the cache, and they are managed by
7:57:45 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
7:57:46 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
7:57:46 PM: npm WARN config location in the cache, and they are managed by
7:57:46 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
7:57:49 PM: npm WARN ERESOLVE overriding peer dependency
7:57:49 PM: npm WARN While resolving: eslint-config-react-app@6.0.0
7:57:49 PM: npm WARN Found: @typescript-eslint/eslint-plugin@5.23.0
7:57:49 PM: npm WARN node_modules/@typescript-eslint/eslint-plugin
7:57:49 PM: npm WARN   dev @typescript-eslint/eslint-plugin@"^5.23.0" from the root project
7:57:49 PM: npm WARN
7:57:49 PM: npm WARN Could not resolve dependency:
7:57:49 PM: npm WARN peer @typescript-eslint/eslint-plugin@"^4.0.0" from eslint-config-react-app@6.0.0
7:57:49 PM: npm WARN node_modules/eslint-config-react-app
7:57:49 PM: npm WARN   eslint-config-react-app@"^6.0.0" from gatsby@4.14.0
7:57:49 PM: npm WARN   node_modules/gatsby
7:57:49 PM: npm WARN
7:57:49 PM: npm WARN Conflicting peer dependency: @typescript-eslint/eslint-plugin@4.33.0
7:57:49 PM: npm WARN node_modules/@typescript-eslint/eslint-plugin
7:57:49 PM: npm WARN   peer @typescript-eslint/eslint-plugin@"^4.0.0" from eslint-config-react-app@6.0.0
7:57:49 PM: npm WARN   node_modules/eslint-config-react-app
7:57:49 PM: npm WARN     eslint-config-react-app@"^6.0.0" from gatsby@4.14.0
7:57:49 PM: npm WARN     node_modules/gatsby
7:57:49 PM: npm WARN ERESOLVE overriding peer dependency
7:57:49 PM: npm WARN While resolving: eslint-config-react-app@6.0.0
7:57:50 PM: Creating deploy upload records
7:57:49 PM: npm WARN Found: @typescript-eslint/parser@5.23.0
7:57:49 PM: npm WARN node_modules/@typescript-eslint/parser
7:57:49 PM: npm WARN   dev @typescript-eslint/parser@"^5.23.0" from the root project
7:57:49 PM: npm WARN   1 more (@typescript-eslint/eslint-plugin)
7:57:49 PM: npm WARN
7:57:49 PM: npm WARN Could not resolve dependency:
7:57:50 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
7:57:49 PM: npm WARN peer @typescript-eslint/parser@"^4.0.0" from eslint-config-react-app@6.0.0
7:57:49 PM: npm WARN node_modules/eslint-config-react-app
7:57:49 PM: npm WARN   eslint-config-react-app@"^6.0.0" from gatsby@4.14.0
7:57:49 PM: npm WARN   node_modules/gatsby
7:57:49 PM: npm WARN
7:57:49 PM: npm WARN Conflicting peer dependency: @typescript-eslint/parser@4.33.0
7:57:49 PM: npm WARN node_modules/@typescript-eslint/parser
7:57:49 PM: npm WARN   peer @typescript-eslint/parser@"^4.0.0" from eslint-config-react-app@6.0.0
7:57:49 PM: npm WARN   node_modules/eslint-config-react-app
7:57:49 PM: npm WARN     eslint-config-react-app@"^6.0.0" from gatsby@4.14.0
7:57:49 PM: npm WARN     node_modules/gatsby
7:57:49 PM: npm WARN ERESOLVE overriding peer dependency
7:57:49 PM: npm WARN While resolving: eslint-config-react-app@6.0.0
7:57:49 PM: npm WARN Found: eslint@8.15.0
7:57:49 PM: npm WARN node_modules/eslint
7:57:49 PM: npm WARN   dev eslint@"^8.15.0" from the root project
7:57:49 PM: npm WARN   17 more (@babel/eslint-parser, ...)
7:57:49 PM: npm WARN
7:57:49 PM: npm WARN Could not resolve dependency:
7:57:49 PM: npm WARN peer eslint@"^7.5.0" from eslint-config-react-app@6.0.0
7:57:49 PM: npm WARN node_modules/eslint-config-react-app
7:57:49 PM: npm WARN   eslint-config-react-app@"^6.0.0" from gatsby@4.14.0
7:57:49 PM: npm WARN   node_modules/gatsby
7:57:49 PM: npm WARN
7:57:49 PM: npm WARN Conflicting peer dependency: eslint@7.32.0
7:57:49 PM: npm WARN node_modules/eslint
7:57:49 PM: npm WARN   peer eslint@"^7.5.0" from eslint-config-react-app@6.0.0
7:57:49 PM: npm WARN   node_modules/eslint-config-react-app
7:57:49 PM: npm WARN     eslint-config-react-app@"^6.0.0" from gatsby@4.14.0
7:57:49 PM: npm WARN     node_modules/gatsby
7:57:50 PM: npm WARN ERESOLVE overriding peer dependency
7:57:50 PM: npm WARN While resolving: eslint-plugin-flowtype@5.10.0
7:57:50 PM: npm WARN Found: eslint@8.15.0
7:57:50 PM: npm WARN node_modules/eslint
7:57:50 PM: npm WARN   dev eslint@"^8.15.0" from the root project
7:57:50 PM: npm WARN   17 more (@babel/eslint-parser, ...)
7:57:50 PM: npm WARN
7:57:50 PM: npm WARN Could not resolve dependency:
7:57:50 PM: npm WARN peer eslint@"^7.1.0" from eslint-plugin-flowtype@5.10.0
7:57:50 PM: npm WARN node_modules/eslint-plugin-flowtype
7:57:50 PM: npm WARN   peer eslint-plugin-flowtype@"^5.2.0" from eslint-config-react-app@6.0.0
7:57:50 PM: npm WARN   node_modules/eslint-config-react-app
7:57:50 PM: npm WARN   1 more (gatsby)
7:57:50 PM: npm WARN
7:57:50 PM: npm WARN Conflicting peer dependency: eslint@7.32.0
7:57:50 PM: npm WARN node_modules/eslint
7:57:50 PM: npm WARN   peer eslint@"^7.1.0" from eslint-plugin-flowtype@5.10.0
7:57:50 PM: npm WARN   node_modules/eslint-plugin-flowtype
7:57:50 PM: npm WARN     peer eslint-plugin-flowtype@"^5.2.0" from eslint-config-react-app@6.0.0
7:57:50 PM: npm WARN     node_modules/eslint-config-react-app
7:57:50 PM: npm WARN     1 more (gatsby)
7:57:50 PM: npm ERR! code ERESOLVE
7:57:50 PM: npm ERR! ERESOLVE could not resolve
7:57:50 PM: npm ERR!
7:57:50 PM: npm ERR! While resolving: gatsby-plugin-multi-language-sitemap@1.1.0
7:57:50 PM: npm ERR! Found: gatsby@4.14.0
7:57:50 PM: npm ERR! node_modules/gatsby
7:57:50 PM: npm ERR!   gatsby@"^4.14.0" from the root project
7:57:50 PM: npm ERR!   peer gatsby@"^4.0.0-next" from babel-plugin-remove-graphql-queries@4.14.0
7:57:50 PM: npm ERR!   node_modules/babel-plugin-remove-graphql-queries
7:57:50 PM: npm ERR!     babel-plugin-remove-graphql-queries@"^4.14.0" from gatsby@4.14.0
7:57:50 PM: npm ERR!     babel-plugin-remove-graphql-queries@"^4.14.0" from gatsby-plugin-image@2.14.1
7:57:50 PM: npm ERR!     node_modules/gatsby-plugin-image
7:57:50 PM: npm ERR!       gatsby-plugin-image@"^2.14.1" from the root project
7:57:50 PM: npm ERR!       1 more (gatsby-source-datocms)
7:57:50 PM: npm ERR!     1 more (gatsby-plugin-typescript)
7:57:50 PM: npm ERR!   18 more (gatsby-plugin-emotion, gatsby-plugin-eslint, ...)
7:57:50 PM: npm ERR!
7:57:50 PM: npm ERR! Could not resolve dependency:
7:57:50 PM: npm ERR! peer gatsby@"^3.0.0-next.0" from gatsby-plugin-multi-language-sitemap@1.1.0
7:57:50 PM: npm ERR! node_modules/gatsby-plugin-multi-language-sitemap
7:57:50 PM: npm ERR!   gatsby-plugin-multi-language-sitemap@"^1.1.0" from the root project
7:57:50 PM: npm ERR!
7:57:50 PM: npm ERR! Conflicting peer dependency: gatsby@3.14.6
7:57:50 PM: npm ERR! node_modules/gatsby
7:57:50 PM: npm ERR!   peer gatsby@"^3.0.0-next.0" from gatsby-plugin-multi-language-sitemap@1.1.0
7:57:50 PM: npm ERR!   node_modules/gatsby-plugin-multi-language-sitemap
7:57:50 PM: npm ERR!     gatsby-plugin-multi-language-sitemap@"^1.1.0" from the root project
7:57:50 PM: npm ERR!
7:57:50 PM: npm ERR! Fix the upstream dependency conflict, or retry
7:57:50 PM: npm ERR! this command with --force, or --legacy-peer-deps
7:57:50 PM: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
7:57:50 PM: npm ERR!
7:57:50 PM: npm ERR! See /opt/buildhome/.npm/eresolve-report.txt for a full report.
7:57:50 PM: npm ERR! A complete log of this run can be found in:
7:57:50 PM: npm ERR!     /opt/buildhome/.npm/_logs/2022-06-01T23_57_45_984Z-debug-0.log
7:57:50 PM: Error during NPM install
7:57:50 PM: Build was terminated: Build script returned non-zero exit code: 1
7:57:50 PM: Failing build: Failed to build site
7:57:51 PM: Finished processing build request in 59.841606166s

We have run into the same problem. After updating the environment variables with v16.15.0 our builds all seem to be working!

3 Likes

I have the same issue, while using Node v16.15.1 (npm v8.11.0).

@dana-blackbean what do you mean with “updating the environment variables with v16.15.0”?

@nhoizey, you can set an environmental variable in Netlify’s dashboard (Site Settings → Build & Deploy → Environment) to dictate which version of node Netlify uses.

Set a variable with the key NODE_VERSION and value 16.15.0.

5 Likes

This was incredibly helplful to me thank you!

2 Likes

Ok, instead of an environment variable, I used my already existing .nvmrc file to set Node to 16.5.0, and it now works! :+1:

Another fix here: Deploy failed today: Build was terminated: Build script returned non-zero exit code: 1 - #4 by nathanmartin

You can set npm flags in Netlify to build using —force or —legacy-peer-deps. Even if your package-lock file was built using one of those flags, they seem to be broken or ignored by Netlify with 16.15.1.

EDIT: Node introduced this error by changing the way the npm ci command builds sites with 16.15.1. Read more on their github issues page.

Thanks, I had the same issue and resolved it with the NPM_FLAGS environment variable.

This was a massive help, I went right round the houses on a Sanity/Gatsby project, I needed to change NODE_VERSION on both studio and web I think.
Thanks!

Note that, Node 16 has been declared as reaching End Of Life by 2023:

So the long-term solution would be to use NPM_FLAGS instead of downgrading Node Version.

@hrishikesh

Why is NPM_FLAGS needed only starting with npm v8.11.0? We have needed to build with —legacy-peer-deps since npm v7, but suddenly Netlify is requiring an environmental variable to build properly.

I asked this before and didn’t get an answer, but shouldn’t the package-lock file take care of this issue? If I set the proper flags when creating package-lock, I would not expect Netlify to build differently from that.

If we need to use npm flags going forward, I would request supporting the .npmrc file, which already allows us to set flags for a project. At least it would be consistent with your .nvmrc support.

I dropped answering your question, because you seemed to be interested to prove this is a Netlify problem when it simply is not. But to answer your question, a quick Google search shows this:

About this, we could try to pass that on as a feature request (or maybe it already works - I’ve never tried that).

Wait… So you knew the answer to my question before, but didn’t answer because you thought I was slighting Netlify? That’s honestly a bit unprofessional.

Anyways, thank you for the answer. You may want to figure out a way to surface the info about NPM_FLAGS more easily, since it is now required for many (most?) projects.

.npmrc was not working when I initially had this issue, I haven’t tested it since downgrading node.

The issue is from 4 days ago, we had that discussion a week ago - so to answer that part, no I did not know. The only thing I was sure about was this is a Node.js/npm issue and not a Netlify issue. I tried looking back then, but didn’t find anything useful.

This time, i decided to dig again, with different search queries, and landed on that.

I agree,

Surfacing that information would make more sense. I’ll pass this to the docs team to see what the best way for this would be.

1 Like

oh thank God for this! lol. this fixed my problem, and I learned something new! I was panicking!

1 Like