Nodejs uses the various postures of the Taobao NPM mirror station

Source: Internet
Author: User
Nodejs Mirroring Configuration

Nodejs and NPM Warehouse hosted on the S3, in the domestic access is very difficult, here can use Taobao Mirror station npm.taobao.org instead. Here are several different ways to use the Nodejs image of Taobao: NVM using Taobao image

Many people will use NVM to manage the local Nodejs version. NVM supports the download addresses of Nodejs and IOJS via environment variables.

Configure these two environment variables: Nvm_nodejs_org_mirror:https://npm.taobao.org/mirrors/node nvm_iojs_org_mirror:https:// npm.taobao.org/mirrors/iojs/

The Linux/unix system uses the following command to set this environment variable:

Export Nvm_nodejs_org_mirror=https://npm.taobao.org/mirrors/node
Export nvm_iojs_org_mirror=https:// Npm.taobao.org/mirrors/iojs

Permanently enforced please add yourself to the Shell's startup script configuration (bash can be added to the ~/.bashrc,zsh can be added to ~/.ZSHRC).

Then NVM ls-remote and NVM Install command will use the image of Taobao. NPM uses Taobao mirrored installation package

NPM uses the registry attribute to specify the warehouse, so configure this property. Several ways to modify the NPM configuration properties are detailed in the official documentation.

Here only to modify the registry method, the following three kinds of any one can: Modify ~/.NPMRC file (No on their own new one), write Registry = https://registry.npm.taobao.org Use the command NPM Config Set registry https://registry.npm.taobao.org (effect and above equivalent) Add environment variable npm_config_registry=https://registry.npm.taobao.org

In the same way, Disturl this configuration will also point to: https://npm.taobao.org/dist, any option:

NPM Config set Disturl https://npm.taobao.org/dist
Node-sass/phantomjs/electron use Taobao Mirror station

Some packages are installed to download precompiled binary formats, such as Node-sass/phantomjs/electron and so on, and most of these packages will be compiled into the finished product hosted on the S3.

Fortunately, these packages have the means to specify the path of the download, interested can read the package of the installation code, will go from the environment variable or NPMRC configuration read the download path, here only posted NPMRC scheme. The same is true for NPM environment variable configuration scenarios:

NPM config set electron_mirror https://npm.taobao.org/mirrors/electron/
npm config set sass_binary_site https:// npm.taobao.org/mirrors/node-sass/
npm config set Phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs/

Then try npm install Phantomjs-prebuilt, you will see the download from Taobao Mirror station PHANTOMJS.

Author: Feng Yu ops
Link: http://www.jianshu.com/p/253cb9003411
Source: Jane book
Copyright belongs to the author. Commercial reprint please contact the author to obtain authorization, non-commercial reprint please indicate the source.

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.