How to install npm package while offline?

前端 未结 6 728
余生分开走
余生分开走 2020-12-13 03:52

I\'m working on an offline network and want to install angular-cli using npm. I have a zip file of angular-cli and using the latest node and npm version. I\'m using the comm

6条回答
  •  时光说笑
    2020-12-13 04:41

    In 2019, I found none recommended approaches were applicable to an "air gapped" server with no internet access.

    I found the only solution was to, on windows, using artillery.io as an example:

    1. install the package on a machine with internet access, e.g local dev machine. npm install -g artillery
    2. Browse to C:\Users\{username}\npm
    3. zip up the \node_modules\artillery (e.g artillery.7z)
    4. Copy the zip and the files artillery, artillery.cmd (at root of npm folder) to the server
    5. Paste the two artillery, artillery.cmd to the root of the servers npm folder (C:\Users\{serverusername}\npm)
    6. Extract the zip to C:\Users\{serverusername}\npm\node_modules

    This is the complicated version for just one tool. If your local machine's npm folder is relatively light on tools, you could always just zip the whole npm folder and copy + extract it on the server.

    I still think it's odd that npm insists on trying to connect to the registry even when using npm pack and npm install -g

提交回复
热议问题