Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
540 views
in Technique[技术] by (71.8m points)

node.js - 如何在Node JS中卸载NPM模块?(How to uninstall npm modules in node js?)

As commonly known, any npm module can be installed by running a simple command: npm install <module_name> .

(众所周知,可以通过运行一个简单的命令来安装任何npm模块: 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:

(我对此有一些疑问:)

  • 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?

    (我们是否有任何命令或过程从根目录卸载模块(类似于npm uninstall <module_name> ),还是只是删除模块文件呢?)

  • How does it affect us if we keep the unused modules?

    (如果我们保留未使用的模块,它将对我们有何影响?)

  ask by Manish Kumar translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The command is simply npm uninstall <name>

(该命令只是npm uninstall <name>)

The nodejs documents https://npmjs.org/doc/ have all the commands that you need to know with npm.

(nodejs文档https://npmjs.org/doc/具有npm需要了解的所有命令。)

A local install will be in the node_modules/ directory of your application.

(本地安装将在应用程序的node_modules/目录中。)

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.

(但是,如果要删除全局软件包,则引用该全局软件包的所有应用程序都将崩溃。)

Here are different options:

(这是不同的选项:)

npm uninstall <name> removes the module from node_modules , but not package.json

(npm uninstall <name>将从node_modules删除模块,但不会从package.json删除)

npm uninstall <name> --save also removes it from dependencies in package.json

(npm uninstall <name> --save还将其从package.json dependencies中删除)

npm uninstall <name> --save-dev also removes it from devDependencies in package.json

(npm uninstall <name> --save-dev还将其从package.json devDependencies中删除)

npm -g uninstall <name> --save also removes it globally

(npm -g uninstall <name> --save也将其全局删除)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...