{

Netlify update node and npm version for production


Change nodejs version in netlify

This short tutorials explain How to set node and npm versions in netlify?

This post answers the below questions

  • set the latest nodejs version in netlify
  • upgrade node and npm versions production build
  • Change outdated nodejs version

There are multiple ways we can upgrade the node version.

The first way, use the .nvmrcfile

Adding .nvmrc file

Go to your project root folder, create a file .nvmrc

Add the node version to it

.nvmrc file:

16.9.0

Upgrade nodejs and npm version using Environment Variables?

Following are steps to add environment variables in

  • First, log in to your netlify account
  • Next, Go to Sites and select the project
  • Select Site Settings
  • Go to the Build & Deploy tab,
  • Go to Environment & Environment variables
  • Please add the below environment variables

These variables are available to build a script for your site.

Please create environment variables with the below values

NODE_VERSION = "16.9.0"
NPM_VERSION = "7.11.1"

Adding node and npm version in netlify.toml file

netlify.toml file contains all build-related configuration for production build of netlify environment

Please add the below values to the netlify.toml file

[context.production.environment]
  HUGO_ENV = "production"
  HUGO_ENABLEGITINFO = "false"
  HUGO_VERSION = "0.89.4"
  
 [build.environment]
  HUGO_VERSION = "0.89.4"
  NODE_VERSION = "16.9.0"
  NPM_VERSION = "7.11.1"

Conclusion

To Sum Up, You learned multiple ways to learn to upgrade nodejs versions in netlify build and deployment.

THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
Subscribe
You'll get a notification every time a post gets published here.