Error installing i2c-bus for PCA9865 node

Hi i tried installing PCA9856 node but it needs i2c-bus and have this errors

pi@raspberrypi:~ $ sudo npm install -g i2c-bus

i2c-bus@4.0.9 install /usr/lib/node_modules/i2c-bus
node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/10.15.3"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/tmp/.node-gyp"
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/i2c-bus/build'
gyp ERR! System Linux 4.14.98-v7+
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/i2c-bus
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! i2c-bus@4.0.9 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the i2c-bus@4.0.9 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-04-06T16_13_22_138Z-debug.log

how do i resolve this?

Thank you

where have you downloaded the node from?

Does it say to use sudo?

Which node red node is it that needs that? It should have installed it automatically.

i tried npm install i2c-bus i still have errors.

i m trying to install this node https://flows.nodered.org/node/node-red-contrib-pca9685

It's advisable to install the i2c package first. Refer to The i2c npm page for more informations. This may require manual steps (e.g. enabling kernel modules). Please only proceed with this module once you've managed to properly install the i2c package, to simplify troubleshooting.

I tried installing i2c package as suggested i have node-gyp errors also so i m trying i2c-bus.

Thank you

I don't see where in those instructions it says to use sudo or install it globally, but I don't think that is what is causing the errors. If you look in the issues on that node (i2c-bus) on github you will see others having similar problems, it seems it is not compatible with node 10.x. It has not been updated for three years and there does not seem to be any response to the mulitple issues raised against it. I think maybe there is a better i2c node, though I have no experience of them.

Is there a reason you installed using sudo ?

I just installed the library in the standard way. The installation was smooth and error free.

r-01

Running on a Raspberry pi:

7 Apr 04:02:29 - [info] Node-RED version: v0.19.5
7 Apr 04:02:29 - [info] Node.js version: v10.14.1
7 Apr 04:02:29 - [info] Linux 4.14.79-v7+ arm LE

Hi Andrei ,

Can you help me to try install this ? https://flows.nodered.org/node/node-red-contrib-pca9685

I managed to install the i2c-bus seems not working with pca9685,
npm install i2c i still cant install it.

Thank you

If you still can't install it after following the instructions what is the error message you see?

Hey, i actually face the same issues on an Raspberry Pi.

i2c.target.mk:99: recipe for target 'Release/obj.target/i2c/src/i2c.o' failed

make: *** [Release/obj.target/i2c/src/i2c.o] Error 1

make: Leaving directory '/home/pi/.node-red/node_modules/i2c-bus/build'

gyp ERR! build error

gyp ERR! stack Error: make failed with exit code: 2

gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)

gyp ERR! stack at ChildProcess.emit (events.js:189:13)

gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)

gyp ERR! System Linux 4.14.98-v7+

gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"

gyp ERR! cwd /home/pi/.node-red/node_modules/i2c-bus

gyp ERR! node -v v10.15.3

gyp ERR! node-gyp -v v3.8.0

gyp ERR! not ok

npm WARN node-red-project@0.0.1 No repository field.

npm WARN node-red-project@0.0.1 No license field.

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! i2c-bus@1.1.2 install: node-gyp rebuild

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the i2c-bus@1.1.2 install script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR! /home/pi/.npm/_logs/2019-04-07T08_40_46_717Z-debug.log

I could help myself by downgrading the node version (with nvm) to v8.-ish.
Then node-red-contrib-pca9685 worked, however other nodes like sqlite3
did not anymore. So downgrading is not an option for me.

You would also need to remove and reinstall / rebuild sqlite node as that also needs to compile against the correct node version

Hi thank you for the suggestions.

Its working fine now
Thank you

So what did you end up doing to get it to work?

I downgrade it as suggested by mrgrizzly above.

  1. https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

  2. npm install i2c-bus

  3. downgrade nodejs to v8.15.1
    https://www.abeautifulsite.net/how-to-upgrade-or-downgrade-nodejs-using-npm

  4. Install node-red-contrib-pca9685 via node-red pallete

Thank you.

The above steps seems to work with jessie bt not stretch. I fresh installed stretch n followed the steps i can install PCA9685 node but whn run it doesnt work. Hope there's better solutions

Thank you.

I would suggest you contact the author (as it is a contrib node) to make them aware of the issues you are having

Have followed the steps but no luck, any suggestions?

Step 1-3

pi@6ftTank:~ mkdir ~/.npm-global pi@6ftTank:~ npm config set prefix '~/.npm-global'
pi@6ftTank:~ $ export PATH=~/.npm-global/bin:PATH pi@6ftTank:~ export PATH=~/.npm-global/bin:PATH pi@6ftTank:~ source ~/.profile
pi@6ftTank:~ $ npm install -g jshint
/home/pi/.npm-global/bin/jshint -> /home/pi/.npm-global/lib/node_modules/jshint/bin/jshint

  • jshint@2.10.2
    added 30 packages from 15 contributors in 9.733s
    pi@6ftTank:~ $ npm install i2c-bus

i2c-bus@4.0.9 install /home/pi/node_modules/i2c-bus
node-gyp rebuild

make: Entering directory '/home/pi/node_modules/i2c-bus/build'
CXX(target) Release/obj.target/i2c/src/i2c.o
SOLINK_MODULE(target) Release/obj.target/i2c.node
COPY Release/i2c.node
make: Leaving directory '/home/pi/node_modules/i2c-bus/build'
npm WARN saveError ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN pi No description
npm WARN pi No repository field.
npm WARN pi No README data
npm WARN pi No license field.

  • i2c-bus@4.0.9
    added 4 packages from 9 contributors and audited 7 packages in 23.351s
    found 0 vulnerabilities

pi@6ftTank:~ sudo npm cache clean -f npm WARN using --force I sure hope you know what you are doing. pi@6ftTank:~ sudo npm install -g n
/usr/bin/n -> /usr/lib/node_modules/n/bin/n

pi@6ftTank:~ $ node -v
v10.15.3

Step 4
fails

2019-05-09T12:12:43.990Z [err] gyp
2019-05-09T12:12:43.990Z [err] ERR!
2019-05-09T12:12:43.990Z [err]
2019-05-09T12:12:43.990Z [err] node-gyp -v v3.8.0
2019-05-09T12:12:43.991Z [err] gyp
2019-05-09T12:12:43.991Z [err]
2019-05-09T12:12:43.991Z [err] ERR!
2019-05-09T12:12:43.991Z [err] not ok
2019-05-09T12:12:45.046Z [err] npm
2019-05-09T12:12:45.047Z [err] WARN node-red-project@0.0.1 No repository field.
2019-05-09T12:12:45.047Z [err] npm
2019-05-09T12:12:45.048Z [err] WARN
2019-05-09T12:12:45.051Z [err] node-red-project@0.0.1 No license field.
2019-05-09T12:12:45.051Z [err]
2019-05-09T12:12:45.060Z [err] npm
2019-05-09T12:12:45.060Z [err] ERR! code ELIFECYCLE
2019-05-09T12:12:45.061Z [err] npm
2019-05-09T12:12:45.061Z [err] ERR! errno 1
2019-05-09T12:12:45.062Z [err] npm
2019-05-09T12:12:45.063Z [err] ERR! i2c-bus@1.1.2 install: node-gyp rebuild
2019-05-09T12:12:45.063Z [err] npm
2019-05-09T12:12:45.063Z [err] ERR! Exit status 1
2019-05-09T12:12:45.064Z [err] npm
2019-05-09T12:12:45.065Z [err] ERR!
2019-05-09T12:12:45.065Z [err] npm ERR! Failed at the i2c-bus@1.1.2 install script.
2019-05-09T12:12:45.065Z [err] npm
2019-05-09T12:12:45.065Z [err] ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-09T12:12:45.201Z [err]
2019-05-09T12:12:45.201Z [err] npm ERR! A complete log of this run can be found in:
2019-05-09T12:12:45.201Z [err] npm ERR!
2019-05-09T12:12:45.201Z [err] /home/pi/.npm/_logs/2019-05-09T12_12_45_077Z-debug.log
2019-05-09T12:12:45.219Z rc=1

Raspbian jessie or stretch? I used jessie, failed on stretch

Raspberry Pi 3 Model B

PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian