npm installation process and docker deployment optimization

The main process of npm installation:

 

 The point is that the default installation of npm is to use the cache first,

Windows cache path: C: \ Users \ username \ AppData \ Roaming \ npm-cache

Linux cache path: ~ / .npm

At this time, if we encounter some packages that are not easy to download, we can download them in advance, put them in the cache directory, and install them locally during installation.

Or follow the method provided by https://zju.date/yarn-registry/ to change the source of the warehouse.

 

When docker deploys a service, it is not possible to utilize the local cache. I have tried to change the way of the warehouse source, and it is not successful. Finally, after a long wait, a particular package was finally installed successfully.

In order to avoid the next long installation, run the decompression command, copy the node_modules in the docker image, and directly copy it in next time to improve the build speed.

Guess you like

Origin www.cnblogs.com/xiaofish/p/12748589.html