Node-RED - Node install - Error: `gyp` failed with exit code: 1
Node-RED - Node install - Error: `gyp` failed with exit code: 1
我需要安装 "red-contrib-socketcan" - https://flows.nodered.org/node/red-contrib-socketcan
问题是我无法安装它,因为 node-gyp 失败,退出代码为 1。
直到现在我找不到任何解决方案。
我正在使用 Banana Pi - M4,它是 运行 Debian 10 Buster lite
这是输出:
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] ------------------------------------------```
就我而言,我完全错过了以下内容:
ImportError: No module named ast
正常情况下Python应该已经安装好了。所以我只是检查它以确定是否安装了 python & python3。而且还没有安装!
所以我做了以下事情:
正在安装 Python:
apt-get install python3-dev python3-pip
apt-get install python-dev python-pip
和checking/installing ast:
pip3 install ast
pip install ast
现在一切正常!
感谢您对@hardillb 的评论。否则我总是会错过这一行。
据我了解,Ubuntu安装node时会安装python2.7-minimal,而且安装包不包含ast模块。也许 Debian 也是。所以尽量安装full python-2.7
apt install python-2.7
我需要安装 "red-contrib-socketcan" - https://flows.nodered.org/node/red-contrib-socketcan 问题是我无法安装它,因为 node-gyp 失败,退出代码为 1。 直到现在我找不到任何解决方案。 我正在使用 Banana Pi - M4,它是 运行 Debian 10 Buster lite
这是输出:
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] ------------------------------------------```
就我而言,我完全错过了以下内容:
ImportError: No module named ast
正常情况下Python应该已经安装好了。所以我只是检查它以确定是否安装了 python & python3。而且还没有安装!
所以我做了以下事情:
正在安装 Python:
apt-get install python3-dev python3-pip
apt-get install python-dev python-pip
和checking/installing ast:
pip3 install ast
pip install ast
现在一切正常! 感谢您对@hardillb 的评论。否则我总是会错过这一行。
据我了解,Ubuntu安装node时会安装python2.7-minimal,而且安装包不包含ast模块。也许 Debian 也是。所以尽量安装full python-2.7
apt install python-2.7