How do I set a system wide node version installed via nvm?












1















I use nvm to manage my node versions, but programs that don't start a shell and don't include ~/.nvm/nvm.sh don't know where to find node.



Intellij for example can start node programms via package.json scripts and you can use it in their terminal, but you can't use node programms from node_modules/.bin like flow from the flow-bin package.



Currently I do some manual setup of symlinks like



$ dirname `which node`
/home/me/.nvm/versions/node/v8.9.0/bin
$ export NODE_PATH="/home/me/.nvm/versions/node/v8.9.0/bin"
$ dirname `which node` | xargs ls
node npm npx yarn yarnpkg


for c in `ls $NODE_PATH` ; do 
sudo update-alternatives --install "/usr/bin/$c" "$c" "$NODE_PATH/$c" 1100
sudo update-alternatives --set "$c" "$NODE_PATH/$c"
done


Is there a easier way to persist those settings and get rid of dangling old entries?










share|improve this question





























    1















    I use nvm to manage my node versions, but programs that don't start a shell and don't include ~/.nvm/nvm.sh don't know where to find node.



    Intellij for example can start node programms via package.json scripts and you can use it in their terminal, but you can't use node programms from node_modules/.bin like flow from the flow-bin package.



    Currently I do some manual setup of symlinks like



    $ dirname `which node`
    /home/me/.nvm/versions/node/v8.9.0/bin
    $ export NODE_PATH="/home/me/.nvm/versions/node/v8.9.0/bin"
    $ dirname `which node` | xargs ls
    node npm npx yarn yarnpkg


    for c in `ls $NODE_PATH` ; do 
    sudo update-alternatives --install "/usr/bin/$c" "$c" "$NODE_PATH/$c" 1100
    sudo update-alternatives --set "$c" "$NODE_PATH/$c"
    done


    Is there a easier way to persist those settings and get rid of dangling old entries?










    share|improve this question



























      1












      1








      1








      I use nvm to manage my node versions, but programs that don't start a shell and don't include ~/.nvm/nvm.sh don't know where to find node.



      Intellij for example can start node programms via package.json scripts and you can use it in their terminal, but you can't use node programms from node_modules/.bin like flow from the flow-bin package.



      Currently I do some manual setup of symlinks like



      $ dirname `which node`
      /home/me/.nvm/versions/node/v8.9.0/bin
      $ export NODE_PATH="/home/me/.nvm/versions/node/v8.9.0/bin"
      $ dirname `which node` | xargs ls
      node npm npx yarn yarnpkg


      for c in `ls $NODE_PATH` ; do 
      sudo update-alternatives --install "/usr/bin/$c" "$c" "$NODE_PATH/$c" 1100
      sudo update-alternatives --set "$c" "$NODE_PATH/$c"
      done


      Is there a easier way to persist those settings and get rid of dangling old entries?










      share|improve this question
















      I use nvm to manage my node versions, but programs that don't start a shell and don't include ~/.nvm/nvm.sh don't know where to find node.



      Intellij for example can start node programms via package.json scripts and you can use it in their terminal, but you can't use node programms from node_modules/.bin like flow from the flow-bin package.



      Currently I do some manual setup of symlinks like



      $ dirname `which node`
      /home/me/.nvm/versions/node/v8.9.0/bin
      $ export NODE_PATH="/home/me/.nvm/versions/node/v8.9.0/bin"
      $ dirname `which node` | xargs ls
      node npm npx yarn yarnpkg


      for c in `ls $NODE_PATH` ; do 
      sudo update-alternatives --install "/usr/bin/$c" "$c" "$NODE_PATH/$c" 1100
      sudo update-alternatives --set "$c" "$NODE_PATH/$c"
      done


      Is there a easier way to persist those settings and get rid of dangling old entries?







      nodejs update-alternatives






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 '17 at 11:48









      Gilles

      45.4k13102141




      45.4k13102141










      asked Nov 10 '17 at 10:22









      flobflob

      24329




      24329






















          1 Answer
          1






          active

          oldest

          votes


















          0














          You can set the system-wide Node.js version by typing



          nvm alias default 11.10.0


          Install the version that you would like:



          nvm install 11.10.0


          Set 11.10.0 (or another version) as default:



          nvm alias default 6.1.0


          Verify the current version by running node -v or nvm current






          share|improve this answer


























          • Hi Parvez, thank you for your answer. Sadly it doesn't help with programs that don't start a shell and don't include ~/.nvm/nvm.sh as described in the answer.

            – flob
            Feb 25 at 12:12











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f975006%2fhow-do-i-set-a-system-wide-node-version-installed-via-nvm%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You can set the system-wide Node.js version by typing



          nvm alias default 11.10.0


          Install the version that you would like:



          nvm install 11.10.0


          Set 11.10.0 (or another version) as default:



          nvm alias default 6.1.0


          Verify the current version by running node -v or nvm current






          share|improve this answer


























          • Hi Parvez, thank you for your answer. Sadly it doesn't help with programs that don't start a shell and don't include ~/.nvm/nvm.sh as described in the answer.

            – flob
            Feb 25 at 12:12
















          0














          You can set the system-wide Node.js version by typing



          nvm alias default 11.10.0


          Install the version that you would like:



          nvm install 11.10.0


          Set 11.10.0 (or another version) as default:



          nvm alias default 6.1.0


          Verify the current version by running node -v or nvm current






          share|improve this answer


























          • Hi Parvez, thank you for your answer. Sadly it doesn't help with programs that don't start a shell and don't include ~/.nvm/nvm.sh as described in the answer.

            – flob
            Feb 25 at 12:12














          0












          0








          0







          You can set the system-wide Node.js version by typing



          nvm alias default 11.10.0


          Install the version that you would like:



          nvm install 11.10.0


          Set 11.10.0 (or another version) as default:



          nvm alias default 6.1.0


          Verify the current version by running node -v or nvm current






          share|improve this answer















          You can set the system-wide Node.js version by typing



          nvm alias default 11.10.0


          Install the version that you would like:



          nvm install 11.10.0


          Set 11.10.0 (or another version) as default:



          nvm alias default 6.1.0


          Verify the current version by running node -v or nvm current







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 24 at 19:08









          Zanna

          51.1k13138242




          51.1k13138242










          answered Feb 24 at 18:49









          Parvez KoseParvez Kose

          11




          11













          • Hi Parvez, thank you for your answer. Sadly it doesn't help with programs that don't start a shell and don't include ~/.nvm/nvm.sh as described in the answer.

            – flob
            Feb 25 at 12:12



















          • Hi Parvez, thank you for your answer. Sadly it doesn't help with programs that don't start a shell and don't include ~/.nvm/nvm.sh as described in the answer.

            – flob
            Feb 25 at 12:12

















          Hi Parvez, thank you for your answer. Sadly it doesn't help with programs that don't start a shell and don't include ~/.nvm/nvm.sh as described in the answer.

          – flob
          Feb 25 at 12:12





          Hi Parvez, thank you for your answer. Sadly it doesn't help with programs that don't start a shell and don't include ~/.nvm/nvm.sh as described in the answer.

          – flob
          Feb 25 at 12:12


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f975006%2fhow-do-i-set-a-system-wide-node-version-installed-via-nvm%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

          Mangá

          Eduardo VII do Reino Unido