I'm pretty new to the Linux world, I have a Node application that I would like to distribute through an apt repository, this is what I do for now:Put the node binary inside the Node application folder.Use fpm to build a .deb package which extracts the node code in /opt/myNodeApplication and a sh script called myNodeApplication in /usr/local/bin.The script is something like this: #!/bin/bashcd /opt/myNodeApplication./node app.jsThis allow me to call myNodeApplication from the shell from anywhere. The problem is that I doubt this is the correct way to do it so I would like to have some input on my solution, the questions are:Is it ok to extract the node application in /opt/myNodeApplication? or is there a better place?Where should I put the script to launch the application? I'm pretty sure /usr/local/bin is not the right place since the script is not a bin.Is there a better way to do the whole thing? Maybe not using a script at all?Thank you a lot in advance.
Where to install node application and best way to launch
shell script;path;node.js;deb
Is it ok to extract the node application in /opt/myNodeApplication? or is there a better place?This is more a matter of opinion, but I reckon you're fine doing this. The standard for this kind of thing is the Filesystem Hierarchy Standard, which has more specific requirements for /opt, but it's your packages for your systems so...Where should I put the script to launch the application? I'm pretty sure /usr/local/bin is not the right place since the script is not a bin.If you look at the contents of /usr/bin you'll see that bin directories contain lots of scripts; the point of .../bin directories is just to contain executable commands, regardless of their implementation details. So storing a script in /usr/local/bin to make your application easier to launch is fine.Is there a better way to do the whole thing? Maybe not using a script at all?You could actually make your Node script executable directly, with the following shebang line added at the top:#!/usr/bin/env node(see https://stackoverflow.com/questions/24253027/node-and-shebang-help-executing-via-command-line for details). Then you could rename your app.js to just app and have users run it directly... (This assumes it can run with a working directory other than /opt/myNodeApplication.)If you're interested in packaging Node applications as .deb packages, take a look at npm2deb, it may come in handy.