craigmw / CellarWarden

A wine/beer cellar temperature/humidity monitoring and control app for the Raspberry Pi
32 stars 4 forks source link

Installing node.js and npm #4

Closed jimmy-1990 closed 7 years ago

jimmy-1990 commented 7 years ago

I'm having issues installing the correct version of node.js and npm on my Raspberry Pi 2 Model B running Rasbian Jessie.

Here is the output when I try to install them;

pi@Humidor:~ $ curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -

Installing the NodeSource Node.js v4.x LTS Argon repo...

Populating apt-get cache...

Confirming "jessie" is supported...

Adding the NodeSource signing key to your keyring...

Creating apt sources list file for the NodeSource Node.js v4.x LTS Argon repo...

Running apt-get update for you...

Run apt-get install nodejs (as root) to install Node.js v4.x LTS Argon and npm

pi@Humidor:~ $ sudo apt-get install -y build-essential python-dev nodejs npm Reading package lists... Done Building dependency tree
Reading state information... Done build-essential is already the newest version. python-dev is already the newest version. Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:

The following packages have unmet dependencies: nodejs : Conflicts: npm E: Unable to correct problems, you have held broken packages. pi@Humidor:~ $ sudo apt-get install -y build-essential python-dev nodejs Reading package lists... Done Building dependency tree
Reading state information... Done build-essential is already the newest version. python-dev is already the newest version. The following extra packages will be installed: rlwrap The following NEW packages will be installed: nodejs rlwrap 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/8,069 kB of archives. After this operation, 38.7 MB of additional disk space will be used. Selecting previously unselected package rlwrap. (Reading database ... 32268 files and directories currently installed.) Preparing to unpack .../rlwrap_0.41-1_armhf.deb ... Unpacking rlwrap (0.41-1) ... Selecting previously unselected package nodejs. Preparing to unpack .../nodejs_4.7.0-1nodesource1~jessie1_armhf.deb ... Unpacking nodejs (4.7.0-1nodesource1~jessie1) ... Processing triggers for man-db (2.7.0.2-5) ... Setting up rlwrap (0.41-1) ... update-alternatives: using /usr/bin/rlwrap to provide /usr/bin/readline-editor (readline-editor) in auto mode Setting up nodejs (4.7.0-1nodesource1~jessie1) ... pi@Humidor:~ $ sudo apt-get install -y npm Reading package lists... Done Building dependency tree
Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:

The following packages have unmet dependencies: npm : Depends: nodejs but it is not going to be installed Depends: node-abbrev (>= 1.0.4) but it is not going to be installed Depends: node-ansi (>= 0.3.0-2) but it is not going to be installed Depends: node-ansi-color-table but it is not going to be installed Depends: node-archy but it is not going to be installed Depends: node-block-stream but it is not going to be installed Depends: node-fstream (>= 0.1.22) but it is not going to be installed Depends: node-fstream-ignore but it is not going to be installed Depends: node-github-url-from-git but it is not going to be installed Depends: node-glob (>= 3.1.21) but it is not going to be installed Depends: node-graceful-fs (>= 2.0.0) but it is not going to be installed Depends: node-inherits but it is not going to be installed Depends: node-ini (>= 1.1.0) but it is not going to be installed Depends: node-lockfile but it is not going to be installed Depends: node-lru-cache (>= 2.3.0) but it is not going to be installed Depends: node-minimatch (>= 0.2.11) but it is not going to be installed Depends: node-mkdirp (>= 0.3.3) but it is not going to be installed Depends: node-gyp (>= 0.10.9) but it is not going to be installed Depends: node-nopt (>= 3.0.1) but it is not going to be installed Depends: node-npmlog but it is not going to be installed Depends: node-once but it is not going to be installed Depends: node-osenv but it is not going to be installed Depends: node-read but it is not going to be installed Depends: node-read-package-json (>= 1.1.0) but it is not going to be installed Depends: node-request (>= 2.25.0) but it is not going to be installed Depends: node-retry but it is not going to be installed Depends: node-rimraf (>= 2.2.2) but it is not going to be installed Depends: node-semver (>= 2.1.0) but it is not going to be installed Depends: node-sha but it is not going to be installed Depends: node-slide but it is not going to be installed Depends: node-tar (>= 0.1.18) but it is not going to be installed Depends: node-underscore but it is not going to be installed Depends: node-which but it is not going to be installed E: Unable to correct problems, you have held broken packages. pi@Humidor:~ $

craigmw commented 7 years ago

Hmm, it appears that some parts of node.js v. 6 were not uninstalled, which may explain why v. 4.x did not get set up properly. You could try n, which can be downloaded from:

https://www.npmjs.com/package/n

You could also use node version manager (nvm). In either case, they may be able to fix the broken install of node v. 4 that you have on your system. These packages allow you to specify which version of node.js you want to be operational on your system, which can be useful. Alternatively, it might be easiest to just start over with a fresh install of Raspbian Jesse (sorry to say that) and use the install guide for CellarWarden to install v.4 from the start.

jimmy-1990 commented 7 years ago

I went ahead and re-imaged my SD Card to the newest version of Rasbian Jessie. After updating it and restarting, here is what happened;

pi@10.10.10.124's password:

The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Mon Jan 2 08:36:49 2017 from 10.10.10.108 pi@Humidor:~ $ node -v -bash: node: command not found pi@Humidor:~ $ npm -v -bash: npm: command not found pi@Humidor:~ $ curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -

Installing the NodeSource Node.js v4.x LTS Argon repo...

Populating apt-get cache...

Installing packages required for setup: apt-transport-https...

Confirming "jessie" is supported...

Adding the NodeSource signing key to your keyring...

Creating apt sources list file for the NodeSource Node.js v4.x LTS Argon repo...

Running apt-get update for you...

Run apt-get install nodejs (as root) to install Node.js v4.x LTS Argon and npm

pi@Humidor:~ $ sudo apt-get install -y build-essential python-dev nodejs npm Reading package lists... Done Building dependency tree Reading state information... Done build-essential is already the newest version. Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:

The following packages have unmet dependencies: nodejs : Conflicts: npm E: Unable to correct problems, you have held broken packages. pi@Humidor:~ $ sudo apt-get install -y build-essential python-dev nodejs npm Reading package lists... Done Building dependency tree Reading state information... Done build-essential is already the newest version. Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:

The following packages have unmet dependencies: nodejs : Conflicts: npm E: Unable to correct problems, you have held broken packages. pi@Humidor:~ $ sudo apt-get install -y build-essential python-dev nodejs Reading package lists... Done Building dependency tree Reading state information... Done build-essential is already the newest version. The following extra packages will be installed: libexpat1-dev libpython-dev libpython2.7-dev python2.7-dev rlwrap The following NEW packages will be installed: libexpat1-dev libpython-dev libpython2.7-dev nodejs python-dev python2.7-dev rlwrap 0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded. Need to get 26.4 MB of archives. After this operation, 65.0 MB of additional disk space will be used. Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main libexpat1-dev armhf 2.1.0-6+deb8u3 [115 kB] Get:2 https://deb.nodesource.com/node_4.x/ jessie/main nodejs armhf 4.7.0-1nodesource1~jessie1 [7,999 kB] Get:3 http://mirrordirector.raspbian.org/raspbian/ jessie/main libpython2.7-dev armhf 2.7.9-2+deb8u1 [17.9 MB] Get:4 http://mirrordirector.raspbian.org/raspbian/ jessie/main python-dev armhf 2.7.9-1 [1,188 B] Get:5 http://mirrordirector.raspbian.org/raspbian/ jessie/main libpython-dev armhf 2.7.9-1 [19.6 kB] Get:6 http://mirrordirector.raspbian.org/raspbian/ jessie/main python2.7-dev armhf 2.7.9-2+deb8u1 [287 kB] Get:7 http://mirrordirector.raspbian.org/raspbian/ jessie/main rlwrap armhf 0.41-1 [70.3 kB] Fetched 26.4 MB in 11s (2,343 kB/s) Selecting previously unselected package libexpat1-dev:armhf. (Reading database ... 31291 files and directories currently installed.) Preparing to unpack .../libexpat1-dev_2.1.0-6+deb8u3_armhf.deb ... Unpacking libexpat1-dev:armhf (2.1.0-6+deb8u3) ... Selecting previously unselected package libpython2.7-dev:armhf. Preparing to unpack .../libpython2.7-dev_2.7.9-2+deb8u1_armhf.deb ... Unpacking libpython2.7-dev:armhf (2.7.9-2+deb8u1) ... Selecting previously unselected package libpython-dev:armhf. Preparing to unpack .../libpython-dev_2.7.9-1_armhf.deb ... Unpacking libpython-dev:armhf (2.7.9-1) ... Selecting previously unselected package python2.7-dev. Preparing to unpack .../python2.7-dev_2.7.9-2+deb8u1_armhf.deb ... Unpacking python2.7-dev (2.7.9-2+deb8u1) ... Selecting previously unselected package python-dev. Preparing to unpack .../python-dev_2.7.9-1_armhf.deb ... Unpacking python-dev (2.7.9-1) ... Selecting previously unselected package rlwrap. Preparing to unpack .../rlwrap_0.41-1_armhf.deb ... Unpacking rlwrap (0.41-1) ... Selecting previously unselected package nodejs. Preparing to unpack .../nodejs_4.7.0-1nodesource1~jessie1_armhf.deb ... Unpacking nodejs (4.7.0-1nodesource1~jessie1) ... Processing triggers for man-db (2.7.0.2-5) ... Setting up libexpat1-dev:armhf (2.1.0-6+deb8u3) ... Setting up libpython2.7-dev:armhf (2.7.9-2+deb8u1) ... Setting up libpython-dev:armhf (2.7.9-1) ... Setting up python2.7-dev (2.7.9-2+deb8u1) ... Setting up python-dev (2.7.9-1) ... Setting up rlwrap (0.41-1) ... update-alternatives: using /usr/bin/rlwrap to provide /usr/bin/readline-editor (readline-editor) in auto mode Setting up nodejs (4.7.0-1nodesource1~jessie1) ... pi@Humidor:~ $ sudo apt-get install -y npm Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:

The following packages have unmet dependencies: npm : Depends: nodejs but it is not going to be installed Depends: node-abbrev (>= 1.0.4) but it is not going to be installed Depends: node-ansi (>= 0.3.0-2) but it is not going to be installed Depends: node-ansi-color-table but it is not going to be installed Depends: node-archy but it is not going to be installed Depends: node-block-stream but it is not going to be installed Depends: node-fstream (>= 0.1.22) but it is not going to be installed Depends: node-fstream-ignore but it is not going to be installed Depends: node-github-url-from-git but it is not going to be installed Depends: node-glob (>= 3.1.21) but it is not going to be installed Depends: node-graceful-fs (>= 2.0.0) but it is not going to be installed Depends: node-inherits but it is not going to be installed Depends: node-ini (>= 1.1.0) but it is not going to be installed Depends: node-lockfile but it is not going to be installed Depends: node-lru-cache (>= 2.3.0) but it is not going to be installed Depends: node-minimatch (>= 0.2.11) but it is not going to be installed Depends: node-mkdirp (>= 0.3.3) but it is not going to be installed Depends: node-gyp (>= 0.10.9) but it is not going to be installed Depends: node-nopt (>= 3.0.1) but it is not going to be installed Depends: node-npmlog but it is not going to be installed Depends: node-once but it is not going to be installed Depends: node-osenv but it is not going to be installed Depends: node-read but it is not going to be installed Depends: node-read-package-json (>= 1.1.0) but it is not going to be installed Depends: node-request (>= 2.25.0) but it is not going to be installed Depends: node-retry but it is not going to be installed Depends: node-rimraf (>= 2.2.2) but it is not going to be installed Depends: node-semver (>= 2.1.0) but it is not going to be installed Depends: node-sha but it is not going to be installed Depends: node-slide but it is not going to be installed Depends: node-tar (>= 0.1.18) but it is not going to be installed Depends: node-underscore but it is not going to be installed Depends: node-which but it is not going to be installed E: Unable to correct problems, you have held broken packages. pi@Humidor:~ $

I'm running nvm to install version 4.7.0, but it is taking a long time. I'll let you know what that comes up with.

craigmw commented 7 years ago

Hmm, did you first uninstall the versions of node.js and npm that come standard on Jessie (I think these are 0.12.35 or something like that)? Maybe the current Jessie repo includes some crippled form of node.js. I'll check it out myself. In the meantime, let me know if nvm works to fix this.

jimmy-1990 commented 7 years ago

I'm still waiting on nvm to finish.

But the stock image of Jessie didn't have node or npm. I ran node -v and npm -v and it couldn't find it.

craigmw commented 7 years ago

Okay, let me know if this fixes the issue.

jimmy-1990 commented 7 years ago

I gave up on waiting for nvm.

I ended up using;

wget http://nodejs.org/dist/latest-v4.x/node-v4.7.0-linux-armv7l.tar.gz tar -xvf node-v4.7.0-linux-armv7l.tar.gz cd node-v4.7.0-linux-armv7l sudo cp -R * /usr/local/ sudo reboot

and now it looks like node and npm are installed correctly.

pi@Humidor:~ $ node -v v4.7.0 pi@Humidor:~ $ npm -v 2.15.11

I went back through the rest of your instructions, and everything seems to be working. Thanks!

craigmw commented 7 years ago

Jimmy:

Excellent! Thanks for being patient with this. Let me know how it works for you.

jimmy-1990 commented 7 years ago

It seems to be working for me. I am getting this error though when I open the website;

Could not open alarms logfile: error, Not Found

craigmw commented 7 years ago

Just make an empty file called alarmsLog.csv (note capitalization). You can do so by:

cd /home/pi/CellarW/public

alarmsLog.csv

This will create the missing file. I'll have to fix the github repo because it is missing a blank file for this.

Thanks...

craigmw commented 7 years ago

I've just fixed this, so you can just use git pull to correct this problem.

jimmy-1990 commented 7 years ago

Thanks Craig!

jimmy-1990 commented 7 years ago

Craig,

I've been messing around with this some, and I was wondering what your thoughts were in trying to allow export of the web config to a different web server. For me I have a VPS in the cloud. I would love to have my VPS host the website and have the Pi scp or ftp the updated values every min or two. My home connection has a dynamic IP that changes quite a bit and I haven't found a reliable ddns provider that can change quick enough at times. It can be very annoying.

craigmw commented 7 years ago

Jimmy:

I've not tried this, but theoretically, it should be possible to have another server instead of the RPi itself. This is because the CellarWarden daemon connects to the client(s) via web sockets. So long as your VPN hosted server can connect to the RPi and obtain its web sockets, it should work. I'm sketchy on the details about how to do this though.

Craig