Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If I run npm without -g, it complains about missing files, and fills my home directory with node_modules junk and a package-lock.json I have to "commit"? Why do I want to commit it, and where?

I'm sure you are now going to tell me there is an easy way to fix that too, and I'd be happy if there was, but for me I just want to use npm to install a program or two.



> for me I just want to use npm to install a program or two.

I don't think you're introducing new information. When I wrote my original comment, it was intended to fully acknowledge that this is what's at play. And rereading it, seems like it does that well enough, but I might be wrong.

But in any case, I'll run it with sudo then, is absolutely the wrong thing to do, regardless of the bad choices on NPM's part—on par with I just want to use my online banking, so I'll click through this certificate error, or I just want to take some notes, so I'll grant this mobile app the full permissions it's asking for.

There's a reason I used the phrase "normalization of deviance". It's a phrase that came out of post mortem investigations into simple process failures at NASA that led to proper (catastrophic, life-ending) failures, and an urge to find an answer to the question, "how in the world did we get here?"


The correct way is to use `npm install -g --prefix` to install it into a directory on your path which is writeable by your current user.

I don't think I've ever seen the install instructions for a npm-packaged tool actually say to do this.


Thanks, I'll give that a try in future.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: