I have been talking a lot about permissions, SIP, El Capitan, and how it could change the way we develop. It still could, but at least in the world of Nodejs and npm, things are looking good.
I did find a work around with npm, and it is part of their new documentation on their website. It’s entitled “Fixing npm permissions”. You don’t have to fool with your .profile (and you probably can’t anyway if you’re on the latest OSX operating system), and there is no sudo involved. Remember how I said that third party software had better adapt to Apple changes? Apparently npm has! So if you have been having problems installing npm lately, check out their post “Fixing npm permissions” to find the solution that is best for you. Install globally if you like using npm in CLI in short form rather than long. However, if you do happen across instructions that provide you with (local) long form commands as an alternative to installing globally for the short, go for it. I do.
FYI: Apparently installing Node through Homebrew can cause problems with npm for globally installed packages. One developer even wrote about it and created a fix for the issue stating that once the fix was implemented, you wouldn’t have to use
sudo to install npm modules globally. I personally would not go down that particular route and would stick with the npm solution(s). It’s just an affirmation that when you are using so many different tools on one machine, stuff happens!
It was quite a circuitous route to get to the point where I was confident things were working as they should and without any sacrifices. One thing I learned was about the importance of getting to know one’s favorite tools with a fine tooth comb, and (hopefully) being able to learn directly from their official documentation. Even more important, getting extremely familiar with your most important tool: your computer! Lastly, keeping a running notebook (separate of your developer blog) of everything you are doing, every issue you come across, and the solutions you discover as a result of encountering those issues.
That’s not to say that there won’t ever be any problems between your Mac and other third party software. Not all third party software might be as savvy or proactive as npm!
*Fixing npm permissions (I personally went with option 2 and skipped steps 2-4)
Fixing npm On Mac OS X for Homebrew Users (solution not recommended)
*Denotes official npm documentation.