Seth Berrier's picture

Greetings!

I'm trying to understand exactly how the global packages setup for the Node.js appliance is supposed to work.  I'm finding that global packages (at least in the normal sense) are simply broken with the appliance out of the box.  There are several global packages installed in /usr/local/bin (which are mentioned in the appliance description, pm2, bower, node-inspector, etc).  However, a non-privledged user cannot access these in any way.  If you do an 'npm list -g' nothing shows up.  However, doing 'sudo npm list -g' as a privledged user does list these global packages but I must then also run node as sudo for them to work.  The long-and-short of it, using global packages the traditional way (as I understand it: install global packages with sudo/su, run node without sudo) does not seem to work on this server.

Furthermore, in the details for the appliance it shows commands like this:

su node
npm install -g express

However, the 'node' user is disabled by default (no login allowed) so the first command fails.  It also shows use of the node user in other ways:

su node
pm2 start
...

I'm wondering exactly what is intended with the 'node' user.

The other thing that puzzles me is that the .noderc file mentioned under /etc/skel simply points to npm_packages under the own user's home directory.  So am I right that packages installed with this setting will be 'global' only for that one user?  Other users will not have access to them.

Anyways, I think I don't understand the intent of how this appliance is setup and how global packages are really supposed to work.  Are the global packages in /usr/local/bin supposed to be accessible by a non-privledged instance of node?  Why do I have to run node with sudo to access traditionally installed packages?

Node: I'm fairly new with node but I've been around the block a few times with linux and web development.

TIA!

Seth

Forum: 
Jeremy Davis's picture

You should be able to use the 'node' user account as per the instructions. However, if you launched your server from AWS Marketplace, you'll need to prepend 'su node' with the 'sudo' command. I.e.:
sudo su node

Also keep in mind, that if you want to load the node user's full environment, you'll need to add a dash between su and node. I.e.:

sudo su - node

Otherwise the default su behaviour is to access the filesystem as the node user, but maintains your root (or admin) user environment.

As TurnKey is designed as a server distro, usually you log as the root user (admin in AWS MP instances). And under our default config on the Node appliance, you would then su as the node user to do everything specifically NodeJS related.

That doesn't mean that you couldn't create additional user accounts if you wished, but that's not the way the appliance has been designed. So you'll probably need to adjust things a bit to suit your workflow.

Once you have your head around it, if you can suggest some improvements to the appliance and/or our docs, we'd love to hear about it! :)

Add new comment