Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3956614
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:23:09+00:00 2026-05-20T02:23:09+00:00

In short… First of all, why does npm suggest that it should only run

  • 0

In short…

First of all, why does npm suggest that it should only run as non-root? I highly disbelieve that every other package manager (apt, yum, gem, pacman) is wrong for requiring sudo.

Second, when I follow their suggestion (and run npm install as non-root), it won’t work (because non-root doesn’t have permission to /usr/local/lib). How do I follow their suggestion? I am not going to chown -R $USER /usr/local/lib, because that seems like a very bad idea to me.

Full description…

I installed npm via curl http://npmjs.org/install.sh | sudo sh (the instruction in their README).

When I run sudo npm install mongoose, npm tells me not to run it as root:

npm ERR! sudon't!
npm ERR! sudon't! Running npm as root is not recommended!
npm ERR! sudon't! Seriously, don't do this!
npm ERR! sudon't!

But when I run npm install mongoose without sudo I get the following:

npm info it worked if it ends with ok
npm info using npm@0.2.17
npm info using node@v0.4.0-pre
npm info fetch http://registry.npmjs.org/mongoose/-/mongoose-1.0.7.tgz
npm info calculating sha1 /tmp/npm-1297199132405/1297199132406-0.7044695958029479/tmp.tgz
npm info shasum b3573930a22066fbf3ab745a79329d5eae75b8ae
npm ERR! Could not create /usr/local/lib/node/.npm/.cache/mongoose/1.0.7/package.tgz
npm ERR! Failed creating the tarball.
npm ERR! This is very rare. Perhaps the 'gzip' or 'tar' configs
npm ERR! are set improperly?
npm ERR!
npm ERR! couldn't pack /tmp/npm-1297199132405/1297199132406-0.7044695958029479/contents/package to /usr/local/lib/node/.npm/.cache/mongoose/1.0.7/package.tgz
npm ERR! Error installing mongoose@1.0.7
npm ERR! Error: EACCES, Permission denied '/usr/local/lib/node/.npm/.cache/mongoose'
npm ERR! There appear to be some permission problems
npm ERR! See the section on 'Permission Errors' at
npm ERR!   http://github.com/isaacs/npm#readme
npm ERR! This will get better in the future, I promise.
npm not ok

So it tells me I shouldn’t use sudo, and then doesn’t work if I follow their suggestion.

Which leads to my initial questions above.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T02:23:10+00:00Added an answer on May 20, 2026 at 2:23 am

    Actually, npm does not recommend not running as root. Well, not any more.

    It has changed around the same time that you asked your question. This is how the README looked like on February 7, 2011: "Using sudo with npm is Very Not Recommended. Anyone can publish anything, and package installations can run arbitrary scripts." It was explained later in more detail as "Option 4: HOLY COW NOT RECOMMENDED!! You can just use sudo all the time for everything, and ignore the incredibly obnoxious warnings telling you that you’re insane for doing this."

    See: https://github.com/isaacs/npm/tree/7288a137f3ea7fafc9d4e7d0001a8cd044d3a22e#readme

    Now it is actually considered a recommended technique of installing npm:

    Simple Install – To install npm with one command, do this:

    curl http:/ /npmjs.org/install.sh | sudo sh

    See: https://github.com/isaacs/npm/tree/99f804f43327c49ce045ae2c105995636c847145#readme

    My advice would be to never do it because it means basically this:

    1. find out what the local DNS (or anyone else spoofing the DNS response or poisoning the DNS cache) says is the IP address of npmjs.org
    2. connect with insecure TCP with that IP (or with whoever says it’s his IP) on port 80
    3. trust the router that you think you should talk to (or anyone who gave you the DHCP response said you should talk to) to deliver packets to the right host
    4. possibly go through another layer of transparent caching proxy
    5. trust all other networks between you and the other end of the TCP connection
    6. don’t know for sure who you are connected with
    7. cross your fingers
    8. request install.sh script over insecure HTTP with no verification whatsoever
    9. and then run whatever was returned by whoever you’re talking to with maximum privileges on your machine without even checking what is it.

    As you can see this is really, literally, with no exaggeration giving root shell to whatever you get after asking for a script from the Internet over an insecure connection with no verification whatsoever. There are at least 5 different things that can go wrong here, any of which can lead to an attacker taking total control over your machine:

    1. DHCP spoofing
    2. ARP spoofing
    3. DNS cache poisoning
    4. DNS response spoofing
    5. TCP session hijacking

    Also note that using ‘sh’ instead of ‘sudo sh’ is usually not any less risky unless you run it as a different user who doesn’t have access to your private data, which is usually not the case.

    You should use HTTPS connections if available to download such scripts so you could at least verify who you are talking to, and even then I wouldn’t run it without reading first. Unfortunately npmjs.org has a self-signed certificate so it doesn’t really help in this case.

    Fortunately npm is available on GitHub that has a valid SSL certificate and from where you can download it using secure connection. See: github.com/isaacs/npm for details. But make sure that the npm itself doesn’t use insecure connections to download the files that it downloads – there should be an option in npm config.

    Hope it helps. Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Short Question: Given Clojure's concurrency model, how do I ensure that all LWJGL OpenGL
Short During debug process I see that, all goes right. For debugging purposes, before
Short: how does modelbinding pass objects from view to controller? Long: First, based on
Short one: Am I correct in assuming, that the Samsung Galaxy S wifi 4.0
Short version : I would like the maven-glassfish-plugin to only be executed in the
Short Trying to get table with exact dimensions for a4 print Table's first and
Short Intro Currently I have a UITableView which is filled with custom cells that
Short Version: I have 7 SSISDeploymentManifest files I need to run. Is there a
Short version: I want a way to run somefunction(username) and have it return the
Short question: If I have class that impelemnts FactoryBean interface, how can I get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.