Steps for customizing node installation to change the default installation path of npm global modules

Steps for customizing node installation to change the default installation path of npm global modules

I installed node to the D drive, and I also needed to change the default installation path of the npm global package because I didn't want to take up space on the C drive.

The first step is of course to go to the node official website to download the corresponding version and install it to the D drive. First, create a new nodejs folder on the D drive.

The installation will not create a folder

Download

insert image description here

Select your own installation package, and then select D:\nodeJs when installing.

After the installation is complete, there is no node in the environment variables at this time, so node and npm cannot be found on the desktop. Open the installation folder and create two new folders node_cache and node_global

Global is used to store globally installed modules, such as npm install vue -g

Then open the command window in the installed folder and enter the command to change the default installation path of npm

npm config set prefix "D:\nodejs\node_global"
npm config set cache "D:\nodejs\node_cache"

tips: There is a pit here, remember not to forget the double quotes, otherwise the modification will be wrong

After modifying the installation path, the next step is to modify the environment variables

Right click on the computer -> Properties -> Advanced system settings

insert image description here

insert image description here

Create a new variable in the system

insert image description here

Add a variable, the variable value is node_modules of node, the variable value opens this folder and double-clicks the address bar above

insert image description here

insert image description here

At this time, npm and node can be found on the desktop

Enter the following to check whether the version detection is successfully modified

insert image description here

Changing the default installation path

Find the PATH in the user variables

Add the path D:\nodejs\node_global;

Remember to separate them with semicolons.

Remember to save after adding

Then we can install cnpm to test whether the address is installed successfully.

npm install -g cnpm --registry=https://registry.npm.taobao.org

After the modification is successful, the installation is completed. Under node_global, there will be node_Modes where cnpm can be found.

At the same time, enter cnpm -v in the command box to execute correctly

Under node_global, there will be node_Modes where you can find cnpm

At the same time, enter cnpm -v in the command box to execute correctly

Then it's done.

This concludes this article about the steps to customize node installation and change the default installation path of npm global modules. For more information about node npm installation path, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Tutorial on installing nodejs & npm and configuring global paths in Linux Centos7.2
  • Modify the default configuration path of npm built into Nodejs
  • Setting Nodejs NPM global path under Windows system

<<:  Alibaba Cloud OSS access rights configuration (RAM permission control) implementation

>>:  Detailed tutorial for downloading and installing mysql8.0.21

Recommend

Writing a rock-paper-scissors game in JavaScript

This article shares the specific code for writing...

Vue implements scrollable pop-up window effect

This article shares the specific code of Vue to a...

How to change the domestic source of Ubuntu 20.04 apt

UPD 2020.2.26 Currently Ubuntu 20.04 LTS has not ...

MySQL master-slave principle and configuration details

MySQL master-slave configuration and principle, f...

How to deploy Angular project using Docker

There are two ways to deploy Angular projects wit...

Full process record of Nginx reverse proxy configuration

1. Preparation Install Tomcat on Linux system, us...

Vue ElementUI Form form validation

Form validation is one of the most commonly used ...

Getting Started with Front-End Vue Unit Testing

Table of contents 1. Why do we need unit testing?...

Detailed explanation of the role of static variables in MySQL

Detailed explanation of the role of static variab...

Nginx implements https website configuration code example

https base port 443. It is used for something cal...

How to run Linux commands in the background

Normally, when you run a command in the terminal,...

Usage of if judgment in HTML

In the process of Django web development, when wr...

Detailed explanation of Linux Namespace User

User namespace is a new namespace added in Linux ...