[英]How do I uninstall a package installed using npm link?
When installing a node package using sudo npm link
in the package's directory, how can I uninstall the package once I'm done with development?使用软件包目录中的
sudo npm link
安装节点 package 时,我如何在完成开发后卸载 package?
npm link
installs the package as a symbolic link in the system's global package location ('/usr/local/lib`). npm link
将 package 作为符号链接安装在系统的全局 package 位置('/usr/local/lib`)中。 This allows you to test the package while still developing it, without having to install it over and over again.这使您可以在开发 package 的同时对其进行测试,而无需一遍又一遍地安装它。
Which npm command do I need to run to remove the link again?我需要运行哪个 npm 命令才能再次删除链接?
The package can be uninstalled using the same uninstall or rm command that can be used for removing installed packages.可以使用可用于删除已安装包的相同卸载或rm命令来卸载该包。 The only thing to keep in mind is that the link needs to be uninstalled globally - the
--global
flag needs to be provided.唯一要记住的是链接需要全局卸载 - 需要提供
--global
标志。
In order to uninstall the globally linked foo
package, the following command can be used (using sudo
if 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 ls
command can be used:要检查是否安装了包,可以使用
npm ls
命令:
npm ls --global foo
you can use unlink
to 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
-Module name gulp-task - 模块名称gulp-task
-Project name project-x -项目名称project-x
You want to link gulp-task :你想链接gulp-task :
1: Go to the gulp-task directory then do npm link
this will symlink the project to your global modules 1:转到 gulp-task 目录,然后执行
npm link
这会将项目符号链接到您的全局模块
2: Go to your project project-x then do npm install
make 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 ,我们有两个选择:
1: Go to your project and do npm unlink gulp-task
this will remove the linked installed module 1:转到您的项目并执行
npm unlink gulp-task
这将删除链接的已安装模块
2: Go to the gulp-task directory and do npm unlink
to remove symlink. 2:进入gulp-task目录并执行
npm unlink
以删除符号链接。 Notice we didn't use the name of the module注意我们没有使用模块的名称
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 nvm it will be a different path我的位置
ls -la /usr/local/lib/node_modules/
如果您使用的是nvm ,它将是不同的路径
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 rm
command 2:删除符号链接只是使用
rm
命令
rm gulp-task
make 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
✔️
npm uninstall --global my-package
If you've done something like accidentally npm link
generator-webapp after you've changed it, you can fix it by cloning the right generator and linking that .如果您在更改后意外地执行了
npm link
generator-webapp 之类的操作,则可以通过克隆正确的生成器并链接它来修复它。
git clone https://github.com/yeoman/generator-webapp.git;
# for fixing generator-webapp, replace with your required repository
cd generator-webapp;
npm link;
“npm install”用 npmjs 的版本(在 package.json 中指定)替换使用“npm link”安装的 node_modules 中的所有依赖项
You can undo the link
command with the unlink
command.可以使用
unlink
命令撤消link
命令。
In package包装内
cd ./some-package
npm link
In comsumer消费类
cd ./some-project
npm link some-package
Removing a link should be done in the reverse order - start from the consumers.删除链接应该以相反的顺序完成 - 从消费者开始。
cd ./some-project
npm unlink some-package
In package包装内
cd ./some-package
npm unlink
This worked for me:这对我有用:
check the list of npm global packages:查看 npm 全局包列表:
npm ls --global npm ls --global
uninstall your package:卸载 package:
npm uninstall --global my-package npm 卸载 --global my-package
go to your testbed and unlink the linked package: go 到您的测试平台并取消链接链接的 package:
npm unlink my-package npm 取消链接我的包
navigate to your testbed directory and reinstall packages:导航到您的 testbed 目录并重新安装软件包:
npm install npm安装
restart your testbed server重新启动您的测试台服务器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.