Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to make a node.js file executable using nvm

I'm using nvm to manage my node versions. My node.js executable files used to be sha bang'ed like so #! /usr/local/bin/node but now it seems like I would have to do something like #! /Users/<userName>/.nvm/versions/node/v6.3.1/bin/node to accomplish the same thing.

What's the best way to handle this?

like image 709
Brian Schermerhorn Avatar asked Aug 09 '16 23:08

Brian Schermerhorn


People also ask

Can I use NVM instead of npm?

Instead of using npm to install and uninstall Node versions for your different projects, you can use nvm, which helps you effectively manage your node versions for each project.

Is NVM the best way to install node?

We recommend using a version manager as versions change very quickly. You will likely need to switch between multiple Node. js versions based on the needs of different projects you're working on. Node Version Manager, more commonly called nvm, is the most popular way to install multiple versions of Node.


1 Answers

I am using #!/usr/bin/env node in my node executable and it seems to work. There is a reference here https://en.wikipedia.org/wiki/Shebang_(Unix)#Portability

like image 173
david Avatar answered Sep 24 '22 19:09

david