gpt4 book ai didi

node.js - 拷贝npm全局安装包到本地

转载 作者:搜寻专家 更新时间:2023-10-31 23:52:36 24 4
gpt4 key购买 nike

如果我全局安装了一个 npm 包,并且我想在某个项目中本地安装相同的包,npm 是再次下载该包还是从全局安装文件夹中复制它?如果没有,是否有办法让它做到这一点?

最佳答案

不建议将文件从全局复制到本地。两个地方都安装包是很正常的。

  • 大多数情况下全局包在终端中使用。
  • 本地包用于应用本身。

你也可以使用 npm link 来符号链接(symbolic link)一个全局包

  1. Install it in both places. Seriously, are you that short on diskspace? It’s fine, really. They’re tiny JavaScript programs.
  2. Install itglobally, and then npm link coffee-script or npm link express (ifyou’re on a platform that supports symbolic links.) Then you only needto update the global copy to update all the symlinks as well.

The first option is the best in my opinion. Simple, clear, explicit. Thesecond is really handy if you are going to re-use the same library ina bunch of different projects. (More on npm link in a futureinstallment.)

关于node.js - 拷贝npm全局安装包到本地,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38277639/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com