How to install Node and NPM, so I don't need to use sudo?

I am trying to configure Node.js and NPM on an Ubuntu 14.04 machine, but I have problems. From my first attempt, I continued to receive EACCES errors when trying to install packages (sometimes even with sudo ), so I completely removed node and npm. Now I'm trying to figure out how to install them in such a way as not to require me to run all sudo and not give me EACCES errors.

I would prefer not to use NVM, and besides that, I just found a bunch of scattered partial answers, some of which contradict each other or just use a slightly different syntax.

I would really appreciate help on this. I just switched to Linux from Windows, and I'm trying to configure it to start working again.

+7
linux npm ubuntu
source share
1 answer

The issue that causes EACCES is often a permission issue in two folders:

In the ~ / .npm directory, a permission issue may occur.

The full path to your directory is ~ ~ / .npm: '/Users/YOUR_USERNAME/.npm'; It stores various npm functions. The easiest way to get to your home directory on a unix-based system (I guess on Linux as well) is to enter "cd".

There may also be a problem with permissions on your / usr / local / lib / node_modules.

Here npm tries to store your globally installed modules. This is the system version of the node_modules folder, which you will find mainly in any node.js project that you create and install with dependencies.

I really made a node package that will solve this problem on mac, although I'm not sure about Linux (because the paths to ".npm" and "node_modules" may be different from linux) could you give it a chance? This basically confirms you as the owner of these directories.

Here's the github page:

https://github.com/yvanscher/fixmynode (just note that this package may be deprecated due to a strange build problem with osenv dependency)

If you reinstall node, you can try to change the rights to these commands (which should work on Linux):

sudo chown -R $(whoami) ~ / .npm

sudo chown -R $(whoami) / usr / local / lib / node_modules

NOTE. I am not 100% sure that the paths / usr / local / lib / node_modules and '~ / .npm are correct for Linux based on Node / npm install. Can you post the full error message you get in the terminal?

+18
source share

All Articles