When you install a node.js package, you get the latest version. But, what if you need to get the latest version of the packages in an old project? Let me show you how I do it
Imagine, Below is what we’ve in the package.json
of a project –
{
"name": "projects_sass",
"version": "1.0.0",
"description": "",
"main": "gulpfile.js",
"dependencies": {
"gulp": "^4.0.2"
},
"devDependencies": {
"gulp-autoprefixer": "^7.0.1",
"gulp-cssbeautify": "^2.0.1",
"gulp-sass": "^4.1.0",
"node-sass": "^4.14.1"
},
"author": "WickeDev",
"license": "ISC"
}
Now, We run the npm outdated
to find out the new releases of the packages.
To update the packages to the latest version, We need to install the npm-check-updates
package globally.
npm install -g npm-check-updates
Now we just run this command –
ncu -u
Above command will change the version to the latest in the package.json
file. Then we just have to run this command to update the package files –
npm update
That’s it! We’ve all our node.js dependencies updated to the latest version.