I need to install "red-contrib-socketcan" - https://flows.nodered.org/node/red-contrib-socketcan Problem is that I can't install it because node-gyp failes with exit code 1. Until now I couldn't find any solution. I am using a Banana Pi - M4 and it's running Debian 10 Buster lite
Here's the output:
10 Jan 12:05:02 - [warn] Installation of module red-contrib-socketcan failed:
10 Jan 12:05:02 - [warn] ------------------------------------------
10 Jan 12:05:02 - [warn] Traceback (most recent call last):
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 47, in <module>
import gyp
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 10, in <module>
import gyp.input
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 7, in <module>
import ast
ImportError: No module named ast
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:223:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 4.9.119-BPI-M4-Kernel
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/.node-red/node_modules/socketcan
gyp ERR! node -v v12.14.1
gyp ERR! node-gyp -v v5.0.5
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! socketcan@2.6.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the socketcan@2.6.0 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/2020-01-10T12_05_01_955Z-debug.log
10 Jan 12:05:02 - [warn] ------------------------------------------```
In my case I completely missed the line that says:
ImportError: No module named ast
Normaly Python should have been installed. So I just checked it to be sure if python & python3 is installed. And it wasn't installed!
So I did the following:
Installing Python:
apt-get install python3-dev python3-pip
apt-get install python-dev python-pip
and checking/installing ast:
pip3 install ast
pip install ast
Everything works fine now! Thank you for the Comment @hardillb. Otherwise I always would have missed this line.