Nodejs prefix (global) and cache (cache) settings under Windows

Source: Internet
Author: User

This article was reproduced from: http://www.cnblogs.com/fisheleven/p/6775380.html?utm_source=itdadao&utm_medium=referral

Citation: After installing Nodejs, the global module via NPM is installed by default to ROAMING\NPM under {%userdata%}c:\users\username\appdata\, which is certainly not the right default.

1, install the LTS version of Nodejs, this article is v6.10.2 (includes NPM 3.10.10). The Msi,nodejs installation path is automatically added to the PATH environment variable;

The installation path for this article is: D:\Program Files\nodejs

After the modification is complete:

2, create a new folder under the Nodejs installation path Node_cache is used to store the cache of the download package; that is: D:\Program Files\nodejs\node_cache;

3, run the npm config set cache "D:\Program Files\nodejs\node_cache" to set the caching folder;

Run npm config set prefix "D:\Program Files\nodejs" to set the global module storage path;

Note: Nodejs will automatically look for the path under the path to the Node_modules folder to actually store the global module, which is why prefix is not called global;

Later installed global modules will be placed under D:\Program files\nodejs\node_modules, with NPM module in a folder;

4, modify the D:\Program FILES\NODEJS\NODE_MODULES\NPM\NPMRC file and change the default value to:

Prefix=d:\program Files\nodejs, if you do not make this modification, NPM will still use the default path to find the installed global module when running NPM ls-g;

5, run npm install express-g Global Installation Express module, can be found in D:\Program Files\nodejs\node_modules under the Express folder;

6. Run npm list-g , listing all global modules:

D:\Program Files\nodejs
+--[email protected]
| +--[email protected]
| | +--[email protected]
| | | '---[email protected]
| | '---[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| | '---[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| | +--[email protected]
| | | '---[email protected]
| | '---[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| | '---[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| | +--[email protected]
| | '---[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | | '---[email protected]
| | '---[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| | '---[email protected]
| +--[email protected]
| '---[email protected]
'---[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
| '---[email protected]
| '---[email protected]
| '---[email protected]
+--[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
| '---[email protected]
| '---[email protected]
| '---[email protected]
| +--[email protected]
| '---[email protected]
+--[email protected]
| +--[email protected]
| +--[email protected]
| | '---[email protected]
| | +--[email protected]
| | '---[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
| +--[email protected]
| | +--[email protected]
| | | '---[email protected]
| | | +--[email protected]
| | | '---[email protected]
| | '---[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
| +--[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
| '---[email protected]
+--[email protected]
| +--[email protected]
| | '---[email protected]
| | +--[email protected]
| | '---[email protected]
| +--[email protected]
| | +--[email protected]
| | | '---[email protected]
| | +--[email protected]
| | +--[email protected]
| | | +--[email protected]
| | | +--[email protected]
| | | +--[email protected]
| | | +--[email protected]
| | | | +--[email protected]
| | | | | '---[email protected]
| | | | '---[email protected]
| | | | '---[email protected]
| | | '---[email protected]
| | '---[email protected]
| '---[email protected]
| '---[email protected]
| +--[email protected]
| | '---[email protected]
| '---[email protected]
| +--[email protected]
| '---[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
| '---[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
| +--Concat-[email protected]
| | +--[email protected]
| | | +--[email protected]
| | | +--[email protected]
| | | +--[email protected]
| | | +--[email protected]
| | | '---[email protected]
| | '---[email protected]
| +--[email protected]
| | +--[email protected]
| | | '---[email protected]
| | +--[email protected]
| | +--[email protected]
| | | +--[email protected]
| | | +--[email protected]
| | | +--[email protected]
| | | +--[email protected]
| | | | +--[email protected]
| | | | | '---[email protected]
| | | | '---[email protected]
| | | | '---[email protected]
| | | '---[email protected]
| | '---[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
| +--[email protected]
| | '---[email protected]
| +--[email protected]
| +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | | +--[email protected]
| | | | '---[email protected]
| | | '---[email protected]
| | | '---[email protected]
| | '---[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
| +--[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
| '---[email protected]
+--[email protected]
| +--[email protected]
| | +--[email protected]
| | | '---[email protected]
| | | +--[email protected]
| | | '---[email protected]
| | '---[email protected]
| '---[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| | '---[email protected]
| | +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | '---[email protected]
| +--[email protected]
| +--[email protected]
| | '---[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| | '---[email protected]
| +--[email protected]
| | +--[email protected]
| | | +--[email protected]
| | | +--[email protected]
| | | +--[email protected]
| | | '---[email protected]
| | +--[email protected]
| | | '---[email protected]
| | +--[email protected]
| | | +--[email protected]
| | | +--[email protected]
| | | | '---[email protected]
| | | +--[email protected]
| | | '---[email protected]
| | '---[email protected]
| | '---[email protected]
| +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | '---[email protected]
| +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | | +--[email protected]
| | | +--[email protected]
| | | '---[email protected]
| | '---[email protected]
| | +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | +--[email protected]
| | '---[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| | '---[email protected]
| +--[email protected]
| +--[email protected]
| +--[email protected]
| +--Stringst[email protected]
| +--[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
+--[email protected]
| '---[email protected]
+--[email protected]
+--[email protected]
| +--[email protected]
| | '---[email protected]
| '---[email protected]
| +--[email protected]
| '---[email protected]
+--[email protected]
| '---[email protected]
+--[email protected]
| '---[email protected]
+--[email protected]
'---[email protected]

Includes Express and NPM two modules, and their dependent modules;

7, finally a neat freak. The default path in the user environment variable can be deleted;

The method contained in this article does not need to set the path variable separately;

-end-

Nodejs prefix (global) and cache (cache) settings under Windows

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.