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 [email protected] No repository field.
npm WARN [email protected] No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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] ------------------------------------------```
2
Answers
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:
and checking/installing ast:
Everything works fine now! Thank you for the Comment @hardillb. Otherwise I always would have missed this line.
As far as I understand, Ubuntu installs python2.7-minimal when you install node, and the package does not include the ast module. Maybe Debian too. So try to install full python-2.7
apt install python-2.7