npm install local-package 创建 symbolik link

npm install local-package creates symbolik link

我有一个本地 npm 包,我使用 npm install path-to-local-package 安装到我的 nodjes 项目中。问题是当我 运行 npm install 模块作为符号 link 安装在我的 node_modules 中时,当我需要将代码复制到目标设备时会导致问题我应该 运行 打开代码。

有没有办法让 npm install 将本地模块复制到 using projects node_modules 文件夹中?

npm 5.3.0 开始,这是不可能的。

npm install <folder>:

Install the package in the directory as a symlink in the current project. Its dependencies will be installed before it's linked. If sits inside the root of your project, its dependencies may be hoisted to the toplevel node_modules as they would for other types of dependencies.

您可以尝试使用 Sinopia 之类的方式托管本地 npm 注册表,但根据您的问题的范围,这可能比其价值更麻烦。