Reputation: 1362
I have Ubuntu Linux and a CLI NodeJS app which I start with:
$ node myapp.js param1 value1 param2 value2
Now I want to start myapp.js like this:
$ myapp param1 value1 param2 value2
Upvotes: 1
Views: 147
Reputation: 184
First, add a shebang to the beginning of the file:
#!/usr/bin/env node
Copy to somewhere in your PATH (using /usr/local/bin as an example):
$ cp myapp.js /usr/local/bin/myapp
Finally, make it executable:
$ chmod +x /usr/local/bin/myapp
Now your program can be run as:
$ myapp param1 value1 param2 value2
(If the program has dependencies, you will need to install them globally, with the -g
flag)
Upvotes: 2