gpt4 book ai didi

Node.js+npm,我应该使用全局还是本地模块安装?

转载 作者:搜寻专家 更新时间:2023-11-01 00:18:33 24 4
gpt4 key购买 nike

什么时候以及为什么我应该在全局和本地安装 Node 模块?为什么许多手册都有“npm install -g”而其他手册没有?这个项目或操作系统是特定的吗?

最佳答案

摘自官方node.js blog :

In general, the rule of thumb is:

1) If you’re installing something that you want to use in your program, using require('whatever'), then install it locally, at the root of your project.

2) If you’re installing something that you want to use in your shell, on the command line or something, install it globally, so that its binaries end up in your PATH environment variable.

关于Node.js+npm,我应该使用全局还是本地模块安装?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21202544/

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