Node-RED-节点安装-错误:`gyp`失败,退出代码:1

时间:2020-01-10 12:06:21

标签: node.js debian gyp

我需要安装“ 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] ------------------------------------------```

2 个答案:

答案 0 :(得分:1)

就我而言,我完全错过了写着:

的行。

ImportError: No module named ast

通常应已安装Python。所以我只是检查了一下,以确保是否安装了python&python3。并没有安装!

所以我做了以下事情:

安装Python:

apt-get install python3-dev python3-pip
apt-get install python-dev python-pip

并检查/安装ast:

pip3 install ast 
pip install ast

现在一切正常! 感谢您对@hardillb的评论。否则,我总是会错过这一行。

答案 1 :(得分:0)

据我了解,Ubuntu在安装节点时会安装python2.7-minimal,并且该软件包不包含ast模块。也许Debian也是如此。因此,请尝试安装完整的python-2.7

apt install python-2.7