node.js 如何卸载使用 npm 链接安装的软件包?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19094630/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I uninstall a package installed using npm link?
提问by nwinkler
When installing a node package using sudo npm linkin the package's directory, how can I uninstall the package once I'm done with development?
sudo npm link在包目录中安装节点包时,如何在完成开发后卸载该包?
npm linkinstalls the package as a symbolic link in the system's global package location ('/usr/local/lib`). This allows you to test the package while still developing it, without having to install it over and over again.
npm link将包作为符号链接安装在系统的全局包位置 ('/usr/local/lib`)。这允许您在开发包的同时测试它,而不必一遍又一遍地安装它。
Which npm command do I need to run to remove the link again?
我需要运行哪个 npm 命令才能再次删除链接?
回答by nwinkler
The package can be uninstalled using the same uninstallor rmcommand that can be used for removing installed packages. The only thing to keep in mind is that the link needs to be uninstalled globally - the --globalflag needs to be provided.
可以使用可用于删除已安装包的相同uninstall或rm命令来卸载包。唯一要记住的是,需要全局卸载链接 ---global需要提供标志。
In order to uninstall the globally linked foopackage, the following command can be used (using sudoif necessary, depending on your setup and permissions)
为了卸载全局链接foo包,可以使用以下命令(sudo必要时使用,取决于您的设置和权限)
sudo npm rm --global foo
This will uninstall the package.
这将卸载软件包。
To check whether a package is installed, the npm lscommand can be used:
要检查是否安装了软件包,npm ls可以使用以下命令:
npm ls --global foo
回答by Blair Anderson
you can use unlinkto remove the symlink.
您可以使用unlink删除符号链接。
For Example:
例如:
cd ~/projects/node-redis
npm link
cd ~/projects/node-bloggy
npm link redis # links to your local redis
To reinstall from your package.json:
从 package.json 重新安装:
npm unlink redis
npm install
https://www.tachyonstemplates.com/npm-cheat-sheet/#unlinking-a-npm-package-from-an-application
https://www.tachyonstemplates.com/npm-cheat-sheet/#unlinking-a-npm-package-from-an-application
回答by KhaledMohamedP
npm link pain:
npm链接痛苦:
-Module name gulp-task
- 模块名称gulp-task
-Project name project-x
-项目名称项目-x
You want to link gulp-task:
你想链接gulp-task:
1: Go to the gulp-task directory then do npm linkthis will symlink the project to your global modules
1:转到 gulp-task 目录,然后执行npm link此操作会将项目符号链接到您的全局模块
2: Go to your project project-xthen do npm installmake sure to remove the current node_modules directory
2:转到你的项目project-x然后npm install确保删除当前的 node_modules 目录
Now you want to remove this madness and use the real gulp-task, we have two options:
现在你想消除这种疯狂并使用真正的gulp-task,我们有两个选择:
Option 1: Unlink via npm:
选项 1:通过 npm 取消链接:
1: Go to your project and do npm unlink gulp-taskthis will remove the linked installed module
1:转到您的项目并执行npm unlink gulp-task此操作将删除链接的已安装模块
2: Go to the gulp-taskdirectory and do npm unlinkto remove symlink. Notice we didn't use the name of the module
2:转到gulp-task目录并执行npm unlink删除符号链接。注意我们没有使用模块的名称
3: celebrate
3:庆祝
What if this didn't work, verify by locating your global installed module. My are location ls -la /usr/local/lib/node_modules/if you are using nvmit will be a different path
如果这不起作用怎么办,请通过定位您的全局安装模块进行验证。ls -la /usr/local/lib/node_modules/如果您使用的是nvm,我的位置将是不同的路径
Option 2: Remove the symlink like a normal linux guru
选项 2:像普通的 linux 大师一样删除符号链接
1: locate your global dependencies cd /usr/local/lib/node_modules/
1:定位你的全局依赖 cd /usr/local/lib/node_modules/
2: removing symlink is simply using the rmcommand
2:删除符号链接只是使用rm命令
rm gulp-taskmake sure you don't have /at the end
rm gulp-task确保你/最后没有
rm gulp-task/is wrong
rm gulp-task/是错的
rm gulp-task??
rm gulp-task??
回答by Code Whisperer
If you've done something like accidentally npm linkgenerator-webapp after you've changed it, you can fix it by cloning the right generator and linking that.
如果你已经做了一些类似意外npm link你已经改变后,发电机的webapp,您可以通过克隆权发电机和连接解决它认为。
git clone https://github.com/yeoman/generator-webapp.git;
# for fixing generator-webapp, replace with your required repository
cd generator-webapp;
npm link;
回答by Eugenio
"npm install" replaces all dependencies in your node_modules installed with "npm link" with versions from npmjs (specified in your package.json)
“npm install”将使用“npm link”安装的 node_modules 中的所有依赖项替换为来自 npmjs 的版本(在 package.json 中指定)

