简体   繁体   English

修复npm全局软件包符号链接

[英]repair npm global package symlinks

Recently upgraded to OSX Mavericks and had all my npm global module symlinks wiped out! 最近升级到OSX Mavericks,并清除了我所有的npm全局模块符号链接! Reinstalling npm got npm to work again. 重新安装npm使npm重新工作。

Is there a way to have npm recursively go through /usr/local/lib/node_modules/ and create the symlinks in /usr/local/bin for each package? 有没有办法让npm递归地遍历/ usr / local / lib / node_modules /并在/ usr / local / bin中为每个软件包创建符号链接? (yes, it is in my Path) (是的,它在我的路径中)

Is there a way to do this a single package at a time? 有没有办法一次做一个包裹?

My Google-fu is failing me at the moment. 我的Google-fu目前使我失望。 I have over 40 packages and I would hate to have to reinstall all of them or manually create symlinks for all the bins! 我有40多个软件包,我讨厌必须重新安装所有软件包或为所有垃圾箱手动创建符号链接!

OSX 10.9 OSX 10.9
npm 1.4.14 npm 1.4.14
node 0.10.29 节点0.10.29

Run this to rebuild in place without reinstalling: 运行此命令以在不重新安装的情况下进行重建:

for i in "$(npm prefix -g)/lib/node_modules/"*; do
  sudo npm build -g "$i"
done

But, are you sure that the symlinks are broken, and not that it simply changed your PATH environment variable or something? 但是,您确定符号链接已断开,而不是它只是更改了PATH环境变量或其他内容吗? What does npm bin -g output? npm bin -g输出什么?

Well this way is easy but it will re-download stuff, but it will still probably be faster than trying to script a way to repair them in place without redownloading: 好吧,这种方法很容易,但是它可以重新下载内容,但是它可能比尝试编写无需重新下载就可以修复它们的脚本要快得多:

npm install -g $(ls /usr/local/lib/node_modules)

If you try to manually create the symlinks, you are almost certain to miss some and/or make so mistakes, so I would not recommend that. 如果您尝试手动创建符号链接,几乎可以肯定会错过一些链接和/或犯这样的错误,因此我不建议您这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM