简体   繁体   中英

repair npm global package symlinks

Recently upgraded to OSX Mavericks and had all my npm global module symlinks wiped out! Reinstalling npm got npm to work again.

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? (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. I have over 40 packages and I would hate to have to reinstall all of them or manually create symlinks for all the bins!

OSX 10.9
npm 1.4.14
node 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? What does npm bin -g output?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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