如何在Node JS中卸载NPM模块?
众所周知,可以通过运行一个简单的命令npm install <module_name>
来安装任何npm模块.
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 anymore and I just want to get them off. I have a few questions regarding this:
-
我们是否有任何命令或过程可以从根目录卸载模块(类似于
npm uninstall <module_name>
) 还是会简单地删除模块文件呢?
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 <name>
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 <name>
从node_modules
中删除该模块,但不更新package.json
npm uninstall <name>
removes the module from node_modules
but does not update package.json
npm uninstall <name> --save
还将其从package.json
npm uninstall <name> --save-dev
还将其从package.json
npm uninstall -g <name> --save
也会全局将其删除