Home  >  Article  >  Web Front-end  >  How to modify Nodejs built-in npm default configuration

How to modify Nodejs built-in npm default configuration

php中世界最好的语言
php中世界最好的语言Original
2018-05-30 09:57:492193browse

This time I will show you how to modify the default configuration of Nodejs' built-in npm. What are the precautions for modifying the default configuration of Nodejs's built-in npm? . Here is a practical case, let's take a look.

The built-in npm of Nodejs will install the module by default in the user AppData directory of the c drive (complain: I don’t understand why current software likes to install resources here)

C drive is so small, it will definitely not work. Let’s modify it step by step to D drive

1. Open the cmd command line and check Current configuration

Enter npm config ls

First look at the current npm configuration environment. Since I have modified it, I can see the modified path

2. Modify the path

You need to modify two paths here, modulepath and cache path

module corresponds to prefix

cache corresponds to cache

First create two directories on other disks

D:\nodejs\node_modules\npm\node_global_modules
D:\nodejs\node_modules\npm\node_cache

Then execute them in sequence

npm config set prefix"D:\nodejs\node_modules\npm\node_global_modules"
npm config set cache"D:\nodejs\node_modules\npm\node_cache"

3. Modify the environment Variables

Newly added Environment variable NODE_HOME

Modify Path and add %NODE_HOME%\;%NODE_HOME%\node_modules;%NODE_HOME%\node_modules\npm\node_global_modules\;

4. Test it

Reopen a cmd command line and try to install a plug-in

Execute

npm install cordova -g// -g means to install it globally Directory

After the installation is completed, open the set installation path to see if it is successful

I believe you have mastered the method after reading the case in this article. Please come for more exciting information. Pay attention to other related articles on php Chinese website!

Recommended reading:

Detailed explanation of the use of common built-in functions in JS

How to use js to encapsulate ajax function functions and usage

The above is the detailed content of How to modify Nodejs built-in npm default configuration. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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
Previous article:How to use nodeJs crawlerNext article:How to use nodeJs crawler