Environment variables + node.js

  • I'm trying to install and create environment variables for node.js.

    I know it can be installed via docker, but not sure how I would create environment variables for a docker container, so I tried running manually.

    I've unpacked node.js (linux / arm64) and used the export command in bash:

    Code
    export NODEJS_HOME=/storage/nodejs/node-v10.15.3-linux-arm64
    export PATH=$PATH:$NODEJS_HOME/bin
    echo `node -v`

    This doesn't work even within the same bash script; it says node can't be found.

    I'm a complete newb, sorry if the solution is obvious... thanks for any help.

  • Do you even have folder /storage/nodejs/node-v10.15.3-linux-arm64 ? Because what you wrote is correct and should work - at least it does here:

    Code
    LibreELEC:~/nodejs # node -v
    v10.15.3
  • The folder does exist. If it's relevant, I'm using a custom build for Amlogic S912 by kszaq.

    I tried a fresh OS install and the problem still exists. If there's a way to set environment variables for global use (not just ssh session or bash script) I could test that?

  • Silly me, thought it was 64 bit. The error was "-sh: node: not found" so assumed I was doing something wrong, but it works with 32 bit.

    That aside, how can I set environment variables without them resetting after reboot or closing ssh session?

  • Tried that and NODEJS_HOME is set, but PATH isn't. Is PATH being overwritten by something else?

    node.js.profile:

    Code
    export NODEJS_HOME=/storage/nodejs/node-v10.15.3-linux-armv6l
    export PATH=$PATH:$NODEJS_HOME/bin

    PATH stays as:

    Code
    export PATH='/usr/bin:/usr/sbin:/storage/.kodi/addons/service.system.docker/bin'
  • True, PATH can't be set here because it is overwritten later.

    But bin folder from addon is automatically add to it. So move everything under /storage/.kodi/addons/node.js folder.

    My all commands to make it happen: