我应该在全球范围内安装节点模块吗?

Should I be installing node modules globally?

我在使用命令行方面做得更好了。我现在经常将它用于 foundation、gulp、ionic 等。我一直纠结的一件事是我应该全局安装模块吗?

我刚买了一台新电脑,我正在重新开始。当我执行第一个基础项目或设置 Gulp 时,当它提示我 运行 'npm install' 时,我应该全局安装吗?如果我这样做,下次我设置基础项目时是否需要 运行 npm install?

这不太适合问答形式,但我通常不建议这样做。全局安装模块可能会对依赖相同包的其他项目产生副作用。

我不知道“基础项目”是什么(而且 Google 没有给出明确的答案),所以我认为你必须添加一个 link 来解释它是什么是。

我认为 NPM 的文档总结得非常好:

If you want to use it as a command line tool, something like the grunt CLI, then you want to install it globally. On the other hand, if you want to depend on the package from your own module using something like Node's require, then you want to install locally.

https://docs.npmjs.com/getting-started/installing-npm-packages-globally

在这种情况下,您应该在本地安装,因为它们是应用程序的依赖项,而不是一般的命令行实用程序。