nodejs10 issue
Hi,
I installed nodejs10 via WHM>easyapach 4 then tried to run the commands node -v from cpanel of one domain in the server and got error command not found, so what I want to know has nodejs been installed globally?
I managed to run the command node -v as
but when i tried the same full path for npm
im getting the attached errors so can anyone explain what the errors are and how I can fix them?
/opt/cpanel/ea-nodejs10/bin/node -vbut when i tried the same full path for npm
/opt/cpanel/ea-nodejs10/bin/node -iim getting the attached errors so can anyone explain what the errors are and how I can fix them?
-
Hello @hql, Node should be installed and available to everyone on the server. However, the way the shell finds the executable for the "node" command relies on the $PATH
environment variable. By default, your$PATH
environment variable won't contain the subfolders in/opt/
. You can add it with the following command:export PATH=/opt/cpanel/ea-nodejs10/bin/:$PATH
If you want this added to your$PATH
during login, you can add that to your~/.bashrc
file. Note that it won't take effect until your next login, or until you source your~/.bashrc
file. Does that resolve the issue for you?0 -
Hi, thanks for your response, I only used that path because you suggested it to another member in another post so thought It would apply to us also in this situation () with the path you suggested above I can get the ...node -v to run just fine and it shows the version installed but ...npm -i produces all the errors in the picture above and I don"t quite know what they mean or what I"m doing wrong, could you take a look at the screen shot from my first post and tell me what is wrong ? 0 -
with the path you suggested above I can get the ...node -v to run just fine and it shows the version installed but ...npm -i produces all the errors in the picture above and I don"t quite know what they mean or what I"m doing wrong, could you take a look at the screen shot from my first post and tell me what is wrong ?
To clarify, I wasn't referring to the "path" as in/opt/cpanel/ea-nodejs10/bin/node
, I mean the$PATH
environment variable. The error in your screenshot is saying that "there is no node binary in the current PATH", which is referring to the environment variable available to the npm process. You can check the current environment variable in your shell by running a command likeecho $PATH
. For example, on my test server:[cptest@cl7 ~]$ echo $PATH /usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/cpanel/composer/bin:/home/cptest/.local/bin:/home/cptest/bin
However, if I add the line I mentioned to my .bashrc file and then log out and back in:[cptest@cl7 ~]$ echo 'export PATH=/opt/cpanel/ea-nodejs10/bin/:$PATH' >> ~/.bashrc [cptest@cl7 ~]$ exit logout (then log back in): [cptest@cl7 ~]$ echo $PATH /opt/cpanel/ea-nodejs10/bin/:/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/cpanel/composer/bin:/home/cptest/.local/bin:/home/cptest/bin
Now/opt/cpanel/ea-nodejs10/bin/
is a part of the$PATH
environment variable, which should resolve the error in your screenshot. Does that resolve your issue?0 -
Hi, Thank you for your help, yes this works but it only seems to work in the account i run the above command, so i added the path into the .bash file as you said in WHM so thought it would work on all accounts that have terminal access but when i logged into another account via cpanel and ran the node -v command it wouldnt work and i had to add the full path to the $path like you explained again. So is there anyway to add this globally for all users? 0 -
Hello @hql, To add nodejs to the path for all users, you can use /etc/profile
. For example:# echo 'export PATH=/opt/cpanel/ea-nodejs10/bin/:$PATH' >> /etc/profile
I hope you find this helpful. Please let us know if you have any questions. Best regards0
Please sign in to leave a comment.
Comments
5 comments