Open niklas-englert opened 3 years ago
@niklas-englert thanks for the detailed description of the issue you experienced! I apologize for my delayed response. I just installed the latest version of Raspberry PI OS (2020-08-20) and installed the latest version of Node (v15.2.1) following the instructions in my Beginner's Guide to Installing Node.js on a Raspberry Pi.
I then invoked the following command to install the ds18b20-raspi
package (running as the pi
user):
sudo npm install -g ds18b20-raspi
I was then able to run ds18b20 -v
and the cli version of the package successfully launched.
I'm not sure what is different about your setup. Perhaps you are using a very old version of Node on the Raspberry Pi?
I have to ask when you installed nodejs, you also did so using sudo? Based on my quick read of the guide, that would be the case. You are also running on a Pi3B or Pi4B. I plan on using this for a Pi Zero where I manually install nodejs without using sudo apt-get
.
sudo npm install -g ds18b20-raspi
installs with elevated permissions as you are granting super user permission with sudo. Therein lies the difference.
npm install -g ds18b20-raspi
installs as the current user (likely 'pi' on Raspbian) and not 'root' or 'su'.
@lynniemagoo If a answer of mine is relevant:
I technically do not use sudo
. Since I am already always logged in with the superuser via SSH, that would be redundant.
Here's the snippet of my private setup script I use (if you're interested):
# get dependencies
apt install curl build-essential # ...
# run Node.js setup
# BEFORE THAT!: Check for a newer instructions https://github.com/nodesource/distributions#debinstall
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
apt-get install -y nodejs
# test success
node -v
nodejs -v
npm -v
I normally login as user ‘pi’
Sent from my iPhone
On Feb 8, 2021, at 7:45 PM, Niklas E. notifications@github.com wrote:
@lynniemagoo If an answer is still relevant: I technically do not use sudo. Since I am already always logged in with the superuser via SSH, that would be redundant.
Here's the snippet of my private setup script I use (if you're interested):
get dependencies
apt install curl build-essential # ...
run Node.js setup
BEFORE THAT!: Check for a newer instructions https://github.com/nodesource/distributions#debinstall
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - apt-get install -y nodejs
test success
node -v nodejs -v npm -v — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
Issue:
Calling
ds18b20
does not work on linux machines. Nothing happens on an$ ds18b20
or$ ds18b20 -v
call.Steps to reproduce:
npm install -g ds18b20-raspi
to install this module globally.ds18b20
ords18b20 -v
. See that nothing happens.My bug tracking explained:
$ ls /usr/lib/node_modules/ds18b20-raspi/
. Was correct.$ ls /sys/bus/w1/devices/
. Was correct.ds18b20
via$ type ds18b20
. Command registered under/usr/bin/ds18b20
./usr/bin/ds18b20
is a symbol linking to/usr/lib/node_modules/ds18b20-raspi/cli.js
while JS files aren't executable in shells like that. More on that later.package.js
of this repository.$ node /usr/lib/node_modules/ds18b20-raspi/cli.js [deviceId] [options]
instead of$ ds18b20 [deviceId] [options]
Found long term fix: Reporting this issue and hoping for a fix by the maintainer. – Providing a long term fix in the opened issue.Found cause explained:
To quote the current
package.json
(line 12-14):This does not actually work on an global installation using
npm install -g ds18b20-raspi
. The provided script forbin
has to be a binary or at least an executable, not a JavaScript file.For some reasons this page of the official npm doc may uses a JS file for an example (
{ "bin" : { "myapp" : "./cli.js" } }
), but this apparently doesn't work on no machine on default whatsoever.npm
will just link the given file (bin
object value) in the/usr/bin/
with the given name (bin
object key) and will make this symbol executable. Nothing more.This in particular does not even work if you force it to run with node because of relative paths in
cli.js
remain unresolved under the symbolic location:Proposed fix:
cli.sh
to this repository which redirects to the node file:cli.sh
andcli.js
should be moved in a separat folder calledbin/
. Paths in 1. and 2. have to be adapted to this change of cause.That should do it. Anyway, I really like using this module. Keep up the good work! :+1: :heart:
Appreciatively
Niklas Englert
(English is not my mother tongue; please excuse any errors on my part.)