1

I have a simple CLI application written in Javascript using Node that is for internal use by a small team. It runs in the Linux terminal as a CLI app. The app consists of a single ".js" file and requires a few Node packages. The problem I face now is how to deploy it to our internal team using a simple method that fits with our routine process of keeping end user computers updated.

Our app needs to be installed once per workstation / laptop and to be available to all users on that computer. Any user should be able to open a terminal and enter the command to run the app.

It seems a lot of people have discussed using Javascript for shell programming, but this issue of deploying the completed app is not widely discussed. I have not found anything on the topic. So far I have been recommended solutions that are appropriate for either development environments or web servers.

This app is not a web app and it is not deployed on a server. It needs to run offline. I am also not asking about developing or maintaining the app on a development workstation.

The installation process should ideally be as about simple as installing a shell script in /usr/local/bin and setting permissions so all permitted users on a computer can run it. We are looking for an installation method like this:

  • copy the Javascript file only once to each computer (to a location on the $PATH) and make sure the Node packages are available globally on that computer.

  • I specifically want to avoid having to do an npm install for each user account on each computer.

  • I also want to avoid having to update Node packages for each user account on each computer.

A developer will keep the app updated so it is always compatible with the latest version of the Node packages, and all computers it is deployed on will always have the latest versions of those packages installed.

One specific problem I encountered is discussed here, but the answers assume a different set of requirements (such as the need for "multiple applications running on different package versions").

5
  • For those requirements, if the actual problem is solving the EACCESS error (you should edit the question to include that information), then you should look at the permissions of all directories, and make sure that the user account that manages node packages on each computer has correct permissions. One way to do that is to give /usr/local a special group, set the sticky bit with chmod (see man chmod), make the installing account a member of that group, and don't use sudo for npm install -g. Commented Dec 25, 2019 at 20:28
  • @dirkt - thank you. Your suggestion sounds appropriate. Also, I'm reluctant to edit the question. I don't want to make this question a near duplicate. Commented Dec 26, 2019 at 1:02
  • @dirkt - also, I think your comment would be a good answer to that question. If you want to post it, I'll accept your answer. Commented Dec 26, 2019 at 1:03
  • 1
    What about a packaging solution to create a standalone offline executable package and deploy it as any other software to your workstations? Then you can have a single copy on each machine that every user runs. Something like this one: github.com/zeit/pkg or even Electron (if you like to have a UI too) Commented Feb 7, 2020 at 2:34
  • @Sohail - thanks for the link to pkg. Looks interesting. I already solved this issue, but for next time I will look into pkg. Commented Feb 7, 2020 at 2:46

2 Answers 2

1

For those requirements, if the actual problem is solving the EACCESS error (you should edit the question to include that information), then you should look at the permissions of all directories, and make sure that the user account that manages node packages on each computer has correct permissions.

One way to do that is to give /usr/local a special group, set the sticky bit with chmod (see man chmod), and use chgrp -R on the existing tree.

Then make the installing account a member of that group, and don't use sudo for npm install -g.

(Never using sudo for installations into /usr/local has the additional advantage that you can't accidentally install something somewhere else, for example because you didn't set paths in this local package source correctly.)

Sign up to request clarification or add additional context in comments.

Comments

0

We are using these two approaches for similar deployments:

  • the programs live on a specific network mount. All users can run the same package from there. The developer only updates this package. No copying to local machines.

  • we use a simple deployment script which runs on all machines on logon. It pushes and copies the latest version to the local machine.

5 Comments

I can't use your first option because this needs to work on laptops too when they are not connected to the local network. In your second method, are you installing a copy for every user on every machine or are you installing once (globally) per machine?
If installing locally requires installing a copy for every user on every machine, I think I will abandon Node for the next project.
The issues you describe are not really specific to Node. Any application that needs to run locally on machines without network connectivity nut at some point be installed on that machine. The approach I suggested in the second method is supposed to help this easier by managing this deployment and updates easier by not requiring any user intervention and providing a centralised place for updates. Or have I perhaps misunderstood your question? What technologies other than Node apps would you think could run locally without being installed locally?
yes, we misunderstood each other. I do wish to install locally. I do not wish to install locally multiple times on each device.
Ah sorry. Yes I misunderstood.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.