如何使用 npm 在本地网络中安装所有节点模块? [英] how to use npm to install all node modules in local network?
问题描述
我的节点应用程序将部署在无法访问互联网的银行中.我可以将所有节点模块下载到本地目录中并从中安装,或者只是将 node_modules 复制到银行机器上?任何安全和实用的建议将不胜感激,谢谢.
My node app will deploy in a bank that can't access the internet. Can I download all the node modules in a local directory, and install them from it, or just copy the node_modules to the bank machines? Any safe and practical advise will be highly appreciated, thank you.
或
如何在不使用 internet 的情况下添加 node_modules
依赖项.
OR
How to add node_modules
dependencies without using internet .
推荐答案
将 offline-npm 添加到您的项目中,以提供与 npm 兼容的 tgz 文件,该文件包含使用 npm install 进行离线安装的所有依赖项.
Add offline-npm to your project to serve a npm compatible tgz file wich contains all dependencies for offline installation with npm install.
此外,您可以使用 offline-npm -n 从本地 npm 缓存目录安装包
Additionally you can use offline-npm -n to install packages from your local npm cache directory
安装
npm install -g offline-npm
使用
1) 打开终端并转到您要准备离线使用的项目.这个文件夹需要包含一个 package.json
文件.
1) Open terminal and go to your project you want to prepare for offline use. This folder needs to contain a package.json
file.
2) 准备您的项目以供离线使用
2) Prepare your project for offline use
offline-npm --add
3) 这会更改 package.json 文件并添加一个包含所有依赖项的离线文件夹.
3) This changes the package.json file and adds a offline folder which will contain all your dependencies.
打包你的项目
npm pack
有关详细信息,请访问链接
希望这个回答对你有用.
For more details , visit the Link
Hope this answer gets useful to you .
这篇关于如何使用 npm 在本地网络中安装所有节点模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!