Skip to main content

nodejs10 issue

Comments

5 comments

  • cPanelHB
    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
  • cPanelHB
    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 like echo $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
  • hql
    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
  • SamuelM
    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 regards
    0

Please sign in to leave a comment.