npm offline install global library

The server firewall of the production environment is not under my control. . When npm install, it can't connect to the outside world. . I don't even bother to talk to the security department. . Just try the offline installation solution.

project library

The internal library of the project can directly bring all the packages of the development environment, no need to install it again with npm install

global library

The main problem is the offline installation of global libraries, such as tools like forever.

  1. Install the target library on a machine that can be installed online, and then find the library folder you just downloaded in /path/to/nodejs/lib/node_modules. The dependencies of the library in this folder have already been downloaded.

  2. Transfer the found library folder to the offline machine, and the location can be put back in /path/to/nodejs/lib/node_modules.

  3. Execute the following command

$npm install -g ./forever

In the example, install forever, "./" is to tell npm to install the library of this current folder directly. Generally speaking, there is no need to pull other dependent libraries, so it is finished in seconds.

  1. Another is to add a soft link to the command to facilitate direct invocation
ln -s /path/to/nodejs/bin/forever /usr/local/bin/ 

Get it done. . This is the easiest way I've been groping for a day. .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324937968&siteId=291194637