I have downloaded NodeJS setup and have it inside at /home/deploy/nodejs. I am trying to set its path, but it's not working out. I am logged in as root, and I would like to access nodejs and npm accessible as root as well. For that I tried adding in /root/.bashrc the following content :PATH=/usr/bin/node:/home/deploy/nodejs/bin/PATH=/usr/bin/npm:/home/deploy/nodejs/bin/After that I tried node and npm, but none of them worked. What am I doing wrong?The files in /home/deploy/nodejs/bin are node, node_modules and npm. I tried the .deb installer, but that is not installing npm, only nodejs, so I have to do all this... :-(Updatenpm/home/deploy/nodejs/bin/npm: 1: /home/deploy/nodejs/bin/npm: dirname: not found/home/deploy/nodejs/bin/npm: 2: exec: /node: not found
Debian : Setting path for Node with root accessible globally
linux;bash;debian;shell;bashrc
1) You're overwriting the path which breaks a lot of your system. The correct line would be:PATH=$PATH:/home/deploy/nodejs/binWith that, you're appending something to PATH, instead of overriding it. Also, the PATH consists of directories (and not files), and /usr/bin should be already in it, rendering the first part useless.2) Did you try turning it off and on again? - the .bashrc is only loaded on login, or when using source ~/.bashrc. If you want to change the path system-wide, you should do so in /etc/profile.3) Also, make sure that there is a /home/deploy/nodejs/bin/node file, and that it's executable (should definitely be the case if you installed it correctly, but you can run chmod a+x /home/deploy/nodejs/bin/node /home/deploy/nodejs/bin/npm to be extra-sure)