Home > Web Front-end > JS Tutorial > body text

How to upgrade Node.js via NPM

不言
Release: 2019-03-21 14:11:11
Original
7575 people have browsed it

NPM is a package manager for Nodejs and many other languages. This article is running nodejs v5.4.0 on the system. To install the latest nodejs package on your system. This article introduces you to the best and easiest way to quickly upgrade the node.js version using NPM. Hope it helps.

How to upgrade Node.js via NPM

Steps to upgrade node.js

Use the following steps to install or upgrade node.js to Latest available version.

Check the current NodeJs version

First check the current nodejs version on your system using the following command. This example is v5.4.0.

$ node -v 

v5.4.0
Copy after login

Force clear cache

Force clear all How to upgrade Node.js via NPM caches in the system.

$ sudo How to upgrade Node.js via NPM cache clean -f 

How to upgrade Node.js via NPM WARN using --force I sure hope you know what you are doing.
Copy after login

Install n module

After clearing all caches in the system, now install n module using How to upgrade Node.js via NPM command.

$ sudo How to upgrade Node.js via NPM install -gn
 
/root/.How to upgrade Node.js via NPM-global/bin/n  - > /root/.How to upgrade Node.js via NPM-global/lib/node_modules/n/bin/n 
+ n@2.1.12
Copy after login

Install Nodejs

We use n module to install or update the latest nodejs version on the system.

$ sudo n stable 

     install : node-v11.8.0
       mkdir : /usr/local/n/versions/node/11.8.0
       fetch : https://nodejs.org/dist/v11.8.0/node-v11.8.0-linux-x64.tar.gz
######################################################################## 100.0%
   installed : v11.8.0
Copy after login

Set Binary Linking

Now use the following command to link the node binary with the latest nodejs installation binary.

$ sudo ln -sf /usr/local/n/versions/node/11.8.0/bin/node /usr/bin/node
Copy after login

Check Nodejs version

Finally recheck your nodejs version. You will see it showing the latest version on your system.

$ node -v  

v11.8.0
Copy after login

This article has ended here. For more exciting content, you can pay attention to the JavaScript Tutorial Video column of the PHP Chinese website!

The above is the detailed content of How to upgrade Node.js via NPM. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
npm
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!