如何在 Node.js 中卸载 npm 模块? [英] How can I uninstall npm modules in Node.js?
问题描述
众所周知,任何 npm 模块都可以通过运行一个简单的命令来安装:npm install
.
As commonly known, any npm module can be installed by running a simple command: npm install <module_name>
.
我已经安装了一些不再使用的模块,我只想将它们卸下.我对此有几个问题:
I have installed a few modules that I do not use any more and I just want to get them off. I have a few questions regarding this:
我们是否有任何命令或进程可以从根目录卸载模块(类似于
npm uninstall
)还是简单地删除模块文件呢?
Do we have any command or process to uninstall a module from the root (something like
npm uninstall <module_name>
) or will simply removing the module files do?
保留未使用的模块对我们有什么影响?
How does it affect us if we keep the unused modules?
推荐答案
命令很简单 npm uninstall
Node.js 文档 https://npmjs.org/doc/ 包含您需要的所有命令需要通过 npm 了解.
The Node.js documents https://npmjs.org/doc/ have all the commands that you need to know with npm.
本地安装将位于应用程序的 node_modules/
目录中.如果模块保留在那里而没有对其进行引用,这不会影响应用程序.
A local install will be in the node_modules/
directory of your application. This won't affect the application if a module remains there with no references to it.
但是,如果您要删除一个全局包,任何引用它的应用程序都会崩溃.
If you're removing a global package, however, any applications referencing it will crash.
这里有不同的选项:
npm uninstall
从 node_modules
中删除模块,但不更新 package.json
npm uninstall <name>
removes the module from node_modules
but does not update package.json
npm uninstall
也将其从 package.json
npm uninstall
也会从 package.json
npm uninstall -g <名称>--save
也会全局删除它
这篇关于如何在 Node.js 中卸载 npm 模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!