如何为离线构建创建 NPM 环境

How to create an NPM environment for an offline build

我正在尝试在没有网络连接的服务器上进行 NPM 构建、安装和捆绑

我可以运行在线服务器上构建成功,我可以将需要的目录复制到离线服务器

如何在离线服务器上重现 NPM 环境,以便 NPM 构建、安装和捆绑成功?

我想我应该复制 node_modulespackage-lock.json 以及 运行 和 npm install --offline.

I can run the build successfully on an online server, and I can copy the directories which are required over to the offline server

知道,在可以访问 Internet 的系统上,运行 npm install 创建并使用所有依赖项填充 node_modules 目录。

复制整个应用程序目录,包括 node_modules 目录,允许离线服务器使用所有依赖项。

这是评论中分享的方法:

如果需要更新依赖项,则需要重复这些步骤。