nodejs npm install全局安装和本地安装的区别

2025-03-10 05:35:29
推荐回答(3个)
回答1:

  • 全局安装可以在命令行直接运行(全局模块的真实安装路径在/usr/local/lib/node_modules/下,/usr/local/bin下的可执行文件只是软链接)

  • 本地安装只能在安装目录下运行(./node_modules 下)

比如“npm install -g eslint”,可以在任意命令行窗口输入“eslint -v”查看eslint版本号

参考:http://www.cnblogs.com/chyingp/p/npm-install-difference-between-local-global.html

回答2:

全局安装是安装到你的全局目录的node_module里了,本地安装是安装到你项目的node_module里了

回答3:

以下内容来自脚本之家 http://www.jb51.net/article/50669.htm