简体   繁体   English

如何通过 node 目录中的 package.json 将特定包安装到不同的目录中?

[英]How to install a particular package through package.json in node directory into a different directory?

here is sample package.json file这是示例package.json文件

dependencies {
       "inversify": "^5.0.1"
}

I would like to install the package into different directory inversify_backup under node_modules .我想将软件包安装到inversify_backup下的不同目录node_modules Is there any option to do it有没有办法做到这一点

Is this your folder structure?这是你的文件夹结构吗?

  • node_modules节点模块
    • inversify_backup inversify_backup

Technically you could cd node_modules/inversify_backup then run npm i <package-name> .从技术上讲,您可以cd node_modules/inversify_backup然后运行npm i <package-name>

Although your dependency install would be overwritten when running in production when the build job runs the npm install command.尽管在构建作业运行npm install命令时在生产中运行时,您的依赖项安装将被覆盖。

I would recommend forking the inversify repository and just including it in your code if you need to make changes to the library.如果您需要对库进行更改,我建议分叉 inversify 存储库并将其包含在您的代码中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有没有一种方法可以将package.json文件中的依赖项安装到其他目​​录中? - Is there a way to install dependencies from a package.json file into a different directory? 如何从 node_modules 目录恢复 package.json - How to recover package.json from node_modules directory 如何通过 package.json 下载和安装所有节点模块? - how to download and install all node modules through package.json? package.json 中的根目录 - Root directory in package.json 为什么在“ npm install express”之后,我的目录中没有package.json? - Why after “npm install express” there is no package.json in my directory? npm为自定义模块安装“没有这样的文件或目录&#39;... / package.json&#39;” - npm install “no such file or directory '…/package.json'” for custom modules 在.exe中打包节点和项目目录并运行package.json脚本 - Packaging Node and Project Directory in .exe and running package.json scripts Docker 和节点:ENOENT:没有这样的文件或目录,打开“package.json” - Docker and Node: ENOENT: no such file or directory, open "package.json" 一个 repo 可以在不同的目录中有多个 package.json 吗? - Can a repo have multiple package.json in different directory? 我如何为当前目录和包含package.json文件的子目录安装npm? - How do I npm install for current directory and also subdirectories with package.json files?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM