节点 npm 本地安装覆盖全局安装
如果我在本地安装了节点模块(与我的节点应用程序位于同一文件夹中),它们是否会覆盖相同模块的全局安装?
If I have node modules installed locally (in the same folder as my node app) will they override global installations of the same modules?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的。请参阅此处有关模块解析的文档。而且,需要明确的是,这里的“覆盖”仅意味着本地模块是将被解析到的模块。全局模块将保持不变,其他目录中的 Node.js 应用程序仍然能够使用全局模块。
Edit: it would probably also help to better understand how the global installs with npm work. More info on that is [here](https://nodejs.org/en/blog/npm/npm-1-0-global-vs-local-installation/).
Yes. See the documentation here on module resolution. And, just to be clear, "override" here simply means that the local module is the one that will be resolved to. The global module will be left untouched, and node.js apps in other directories will still be able to use the global module.
Edit: it would probably also help to better understand how the global installs with npm work. More info on that is [here](https://nodejs.org/en/blog/npm/npm-1-0-global-vs-local-installation/).