Netlify update node and npm version for production
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 .nvmrc
file You can also check other posts on npm command deprecate option is deprecated
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
The netlify.toml
file contains all build-related configurations for production build of the 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.