Nvm: Problem with installation

Created on 6 Mar 2017  Â·  5Comments  Â·  Source: nvm-sh/nvm

  • Operating system and version:
    Debian 8
  • nvm debug output:
    No file found

  • nvm ls output:


         v7.7.1
default -> stable (-> v7.7.1)
node -> stable (-> v7.7.1) (default)
stable -> 7.7 (-> v7.7.1) (default)
iojs -> N/A (default)
lts/* -> lts/boron (-> N/A)
lts/argon -> v4.8.0 (-> N/A)
lts/boron -> v6.10.0 (-> N/A)

  • How did you install nvm? (e.g. install script in readme, homebrew):
    su

    here I'm root

which node

nothing

which npm

nothing

adduser nodejs

jaddajadda I create the user

su nodejs
cd ~

here I'm nodejs@debian:~/

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash

Here I exit the terminal, I even tried rebooting.

nvm install stable
nvm alias default stable

jaddajadda everything is installed.

Here I've rebooted again and I'm root again

su nodejs

Error log:

Error: EACCES: permission denied, scandir '/root'

Error: EACCES: permission denied, open 'npm-debug.log.4042825254'

nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v7.7.1 --silent` to unset it.

Note: this error appears every time I change user to nodejs.

I tried running the given command, but when logging as nodejs again it was there again.

su nodejs
node

command not found

nvm install stable
node

here node works

reboot
su nodejs

Errors like before

node

command not found

Note that no commands I'm running are run as su, as I think that's the whole point of it.
So I've that error on the console every time I log to nodejs user, and node stops working every time (it says that it was already installed (after the first time) but the command was not usable). This leads to other consequences and other issues.

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?

No, I'm testing this on a clean installation just out of a debian 8 netinstall ISO. I've created this VM specifically to test this.

NOTE:
I tried following the same step that I described above, except creating the new user, with the default user that I created with Debian's Graphic Installation. Said user was not root or su (access to the /root folder was in fact denied), and with that user everything worked fine.
This issue appears only with the user I created with "adduser".
I'm trying to repeat the whole process again to confirm this (but I broke the original VM snapshot that I use to create clones to test, so currently I'm reinstalling again).
So what's the difference between a user created during system installation and one created with adduser? I see the user created during system installation has a whole load of files and directories in his /home/"user"/, like Downloads, Documents… while the one created with adduser doesn't have all those fancy directories.

Most helpful comment

For others, when switcing users using su the .bashrc wont be sourced. You need to swith to login shell instead of interactive:

su -l $username

source: https://unix.stackexchange.com/a/29811/16043

All 5 comments

When you su, I believe that doesn't reset environment variables.

Log in directly as the user instead of using su, or re-source the user's profile files after switching, and I'd expect it to work.

How do I "re-source" the user's profile files after switching?

. ~/.bashrc, for example

cd ~
source ~/.bashrc

This worked.

Thanks ljharb.

For others, when switcing users using su the .bashrc wont be sourced. You need to swith to login shell instead of interactive:

su -l $username

source: https://unix.stackexchange.com/a/29811/16043

Was this page helpful?
0 / 5 - 0 ratings

Related issues

serbiant picture serbiant  Â·  4Comments

tongxiaofeng picture tongxiaofeng  Â·  5Comments

nickngqs picture nickngqs  Â·  3Comments

raitucarp picture raitucarp  Â·  3Comments

danielepolencic picture danielepolencic  Â·  4Comments