Upgrade NPM and node under Linux

Source: Internet
Author: User
Tags install node

NPM Upgrade

Don't say much nonsense, just talk about the steps. Start with the easy first and upgrade NPM.

NPM This package management tool has been criticized by people, many people recommend the use of yarn, but its number of users are still not reduced, and NPM are installed with node at the same time, let me abandon it, or a bit difficult to do.

npm i -g npm
    • 1

Yes, you've read it right. Upgrading NPM is just like installing a different package, which can be upgraded under Windows and Linux, and you can also specify the version of NPM.

npm i -g [email protected]5.0.0
    • 1
Node upgrade

Node escalation is a bit more complicated than NPM.

1, first install node's version management tool through NPM "n", do not be surprised, the name is so simple, called N. It is understood that N is a module under node, and the author is the developer of the Express framework.

npm i -g n
    • 1

2. Check N module

Check the installation path of the system node first, and the default path for the N module is '/usr/local '.

$ which node/data/home/server/nodejs/bin/node   #举个例子
    • 1
    • 2
    • 3

If the path is the same as the default path of the N module, you can skip 3 steps.

3. Modify the default node installation path for n through the N_prefix variable.

(1) Editing the Environment configuration file

vim ~/.bash_profile   
    • 1

(2) Insert the following two lines of code at the end of the file

export N_PREFIX=/data/home/server/nodejs #node实际安装位置export PATH=$N_PREFIX/bin:$PATH
    • 1
    • 2

(3): Wq save exit;

Executes the source to make the modification effective.

source ~/.bash_profile
    • 1

(4) Confirm that the environment variable is in effect.

echo $N_PREFIX/data/home/server/nodejs
    • 1
    • 2

4, N module common commands

COMMANDS:N Output versions installed n latest Install or activate th E Latest node Release n-a x86 latest as above but force32 bit architecture n Stable Install or activate the latest stable node R                    Elease n lts Install or activate the latest LTS node release n <version>     Install node <version> n use <version> [args for <version> N rm <version 
      
       ...> Remove the given version (s) n prune Remove all versions except the current version n--late St Output the latest node version available n--stable output the latest stable node version available n--lts output the Latest LTS node version available n ls Output the versions of node available 
          
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16

(1) Install node's latest version

n latest
    • 1

(2) Install stable version

n stable
    • 1

(3) Install the specified version

n v7.10.0
    • 1

(4) View installed version

n
    • 1

(5) Delete the specified version

n rm 6.4.0
    • 1

Finally, Linux also has a shell-based node management tool NVM, interested students can also try their own.

Upgrade NPM and node under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.