linux - 执行 npm install -g 时会发生什么

标签 linux node.js

这是一个非常新手的问题。但我真的无法通过谷歌搜索弄明白。 我想了解执行时会发生什么

   sudo npm install -g "node module name"

我知道正确的模块通常会安装到/usr/local/.... 但是,为什么这会在全局范围内可用?

例如,我在项目本地安装了node-inspector。但是当我输入“node-inspector”时,我的 shell 不理解。

但是一旦我全局安装了它,

node-inspector &

命令会为我做正确的事。 我真的很想了解这是怎么发生的。

谢谢

最佳答案

引用 the npm's doc :

  • Local install (default): puts stuff in ./node_modules of the current package root.
  • Global install (with -g): puts stuff in /usr/local or wherever node is installed.
  • Install it locally if you're going to require() it.
  • Install it globally if you're going to run it on the command line.
  • If you need both, then install it in both places, or use npm link.

这是一个相当简短的描述(我想,这仍然足以看出区别),但是链接页面更详细地描述了使用 npm 安装模块的整个过程。 )

关于linux - 执行 npm install -g 时会发生什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13092747/

相关文章:

linux - 在 TLB 访问中设置断点

javascript - 如何在 for 循环中执行嵌套数据库查询?

java - 进行 cordova 平台更新后,Android 目标发生更改

c++ - Amazon AWS CPP SDK 获取 S3 Bucket 下载进度

linux - 在桌面上显示当前目录的常用 Linux 命令是什么?

有人可以向我解释一下这个指针的用法吗?

java - 将 Amazon RDS 与只读副本结合使用时,如何处理最终的不一致问题?

ruby - 如何从 unix 或 windows 格式的给定文件路径获取 ruby​​ 中的基本名称?

javascript - 在重定向期间将 token 从 API 传递到前端

node.js - AS3可以从 header 识别CORS权限吗?