Moteino Framework Gateway setup - npm path issues [solution]

Started by christhomas99, May 05, 2015, 10:50:35 AM

christhomas99

Hi,

Apologies if this is not the correct place for this question, but I thought I would try here first.

I am trying to get the Moteino Framework Gateway up and running using the recently updated instructions.

I have managed to successfully (I think) get to the stage where the socket.io etc are installed as per the following lines:

cd ~/moteino
sudo npm install socket.io
sudo npm install nedb --save
sudo npm install nodemailer

The issue is that when I try and execute any of the install statements, I receive the following:

sudo:nom: command not found

Any help is greatly appreciated!

Thanks in advance,

Chris

Felix

Sounds like npm has some issue?
Did you google the error?
Did you start with a fresh Pi image?

christhomas99

Hi Felix,

Thanks for coming back to me so quickly.

I did start with a completely fresh install of Raspian (v3.18) and followed the guide set out.

Everything seemed to install and if I run npm -v, I get a response of 1.4.9.

I did have an issue with where to put the following lines:

NODE_JS_HOME="/opt/node"
PATH="$PATH:$NODE_JS_HOME/bin"
export PATH

I placed it at the end of the if statement, but I will be honest and say it was more of a guess than science. This is an extract from the file now:

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local$
fi
NODE_JS_HOME="/opt/node"
PATH="$PATH:$NODE_JS_HOME/bin"
export PATH

I have googled the error and there are some comments around setting the PATH, but I am not sure whether this is a red herring or not.

Kind regards,

Chris


ssmall

I have same issue.  npm is not set up in my PATH correctly.

Try this:

cd ~/moteino
which npm     // This should give you the path to npm.  In my case it's: /opt/node/bin/npm
sudo /opt/node/bin/npm install nedb --save  // instead of just npm use the path that came back from which:  /opt/node/bin/npm

christhomas99

Thanks ssmall.

This has just worked! Clearly there is an issue with how I have setup the path statement, so I will do a little further digging on exactly what I have done wrong there later, but at least I can carry on with the installs in the meantime.

Cheers,

Chris

thalx

Curious behavior...
=======================
pi@raspberrypi ~/moteino $ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/opt/node/bin
pi@raspberrypi ~/moteino $ which npm
/opt/node/bin/npm
pi@raspberrypi ~/moteino $ sudo echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/opt/node/bin
pi@raspberrypi ~/moteino $ sudo which npm
pi@raspberrypi ~/moteino $
=====================

But on reading the man page for which, the command 'which' does not follow symbolic links.

=====================
pi@raspberrypi ~/moteino $ ls -l /opt/node/bin/npm
lrwxrwxrwx 1 root root 38 Jul 19 02:26 /opt/node/bin/npm -> ../lib/node_modules/npm/bin/npm-cli.js
=====================

It still seems curious to me that 'sudo' won't find the symbolic link via PATH, but if you give it the direct path to the symbolic link it will execute.

-Chris