6
ddit
5y

How often does this happen to you?

Hmm I need to install the nodemon package, ok so I enter:
npm install -g nodemon
Result:
npm WARN
npm WARN
npm ERR
npm ERR
npm ERR....

I then wonder why would it not work??? Then after looking at the errors I realise ohh:
sudo npm install -g nodemon

This literally happens to me almost every single time I install a package.

Comments
  • 4
    Ehh, isn't there some kind of user-level install? Using sudo sounds like a bad idea for installing packages, at least in python
  • 4
    @alexbrooklyn Not if you're installing it globally. Which begs the question, who still installs these things globally if you can (and SHOULD) put it as a devDepenedency and just run npx nodemon / yarn nodemon?
  • 0
    @hitko
    -g dumps to /usr/local/lib/node_modules, so it shouldn't need sudo. I would suspect if it needs sudo, it's because it's building something.
  • 0
    @M1sf3t you did a lot of things in that vm :p
  • 0
    You broke something
  • 0
    @SortOfTested Since when directories in /usr/local are writable by anyone except root?
  • 0
    @sbiewald
    Seems like full rwxrwx+a on all the arch and fedora installs I have. Maybe someone has gremlin'd my machines? 😮
  • 0
    @SortOfTested It varies by the system & install method, debian-based systems + NodeSource put it in /usr/lib/node_modules, and last time I checked that folder was 755 root:root.

    Just to add to my previous comment, it is possible to install "global" node modules in your home directory by setting a bunch of env variables, but it doesn't always work.
Add Comment