Javascript

Easily update Node.js dependencies to their latest version

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.

S M Zahed Kamal

Recent Posts

PHP to remove unnecessary key and value pairs from any multi-dimensional array

Today I will share a snippet I've used in a project. Using that function, you…

2 years ago

Use vanilla JavaScript to make Ajax request

JavaScript AJAX (Asynchronous JavaScript and XML) is a technique that gives the ability to send…

3 years ago

Add animation to bootstrap carousel elements

By default, Bootstrap carousel has no way to add animations to carousel elements. Here I'm…

3 years ago

Create custom pagination template in Laravel

Laravel comes up with a paginator that generates HTML compatible with the Tailwind CSS framework.…

3 years ago

Add Bootstrap Icons in SASS or SCSS

Bootstrap introduced their icons collection in November 2019 as Bootstrap Icons (v1.0.0-alpha). At that time,…

3 years ago

Create autocomplete using vanilla JavaScript

To create autocomplete feature for input field(s), HTML's datalist tag can be the easiest solution.…

3 years ago