Friday, September 7, 2018

How to install node.js on openelec Kodi

Yet another short how to, I need node.js installed on my OpenElec Kodi box so I can get Google Home to control it. It took a bit of googling and some file editing.

ssh root@box ip

Should be in /storage

Run:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash

It will produce a message about adding some lines to .profile instead of .bashrc, that's okay. Check /storage/.profile, it should have a couple of lines like this:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

Log out, then ssh back to your Openelec box, this will force the new addition to .profile to be used.

Next, fix the nvm script so it works on Openelec.

cd .nvm
nano nvm.sh
Do a "Where Is" command in nano, search for " ls ", that's space, l, s, space, we're looking for an ls command. There are 3 of these:

ls -1qA

Remove the 'q' from all 3, the busybox sh version of ls doesn't support the 'q' option, and that's okay too.

Now install node.js:

nvm install node

This might take a minute or two.

Run the nvm "use" command:

nvm use node

You should see something like:

Now using node v10.10.0 (npm v6.4.1)

Test that node is working:
node -v
Output: v10.10.0

Test that npm (node package manager) works
npm -v
Output: 6.4.1

No comments: