安装 node-red-contrib-jdbc 失败并出现 gyp 配置错误

问题描述 投票:0回答:1

我目前正在尝试使用 Node-RED 测试 IoT 应用程序的多个数据库。要将 Node-RED 与数据库连接,我想使用 node-red-contrib-jdbc 软件包,但安装不起作用(尝试了调色板管理器和通过终端手动安装)。错误消息发布在下面,但我不确定它想告诉我什么,有人知道吗?

系统:Ubuntu 20.04 LTS(虚拟机)
Python:2.7.18 和 3.8.10
Java:openjdk版本“11.0.11”2021-04-20
OpenJDK 运行时环境 (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64位服务器虚拟机(build 11.0.11+9-Ubuntu-0ubuntu2.20.04,混合模式,共享)

错误信息:

> [email protected] install /home/nimda/.node-red/node_modules/java                                                                                                 
> node-gyp rebuild                                                                                                                                            
                                                                                                                                                              
gyp WARN EACCES current user ("nimda") does not have permission to access the dev dir "/root/.cache/node-gyp/14.17.6"                                         
gyp WARN EACCES attempting to reinstall using temporary dev dir "/home/nimda/.node-red/node_modules/java/.node-gyp"                                           
(node:3394) UnhandledPromiseRejectionWarning: TypeError [ERR_STREAM_NULL_VALUES]: May not write null values to stream                                         
    at Socket.Writable.write (internal/streams/writable.js:272:11)                                                                                            
    at /home/nimda/.node-red/node_modules/java/findJavaHome.js:6:18                                                                                           
    at /home/nimda/.node-red/node_modules/find-java-home/dist/index.js:103:21                                                                                 
    at step (/home/nimda/.node-red/node_modules/find-java-home/dist/index.js:46:23)                                                                           
    at Object.next (/home/nimda/.node-red/node_modules/find-java-home/dist/index.js:27:53)                                                                    
    at fulfilled (/home/nimda/.node-red/node_modules/find-java-home/dist/index.js:18:58)                                                                      
(Use `node --trace-warnings ...` to show where the warning was created)                                                                                       
(node:3394) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catc
h block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unha
ndled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)                                               
(node:3394) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate t
he Node.js process with a non-zero exit code.                                                                                                                 
gyp: Call to 'node findJavaHome.js' returned exit status 0 while in binding.gyp. while trying to load binding.gyp                                             
gyp ERR! configure error                                                                                                                                      
gyp ERR! stack Error: `gyp` failed with exit code: 1                                                                                                          
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Linux 5.11.0-34-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/nimda/.node-red/node_modules/java
gyp ERR! node -v v14.17.6
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
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!     /root/.npm/_logs/2021-09-15T14_08_09_489Z-debug.log
ubuntu npm node-red node-gyp gyp
1个回答
0
投票
 does not have permission to access the dev dir "/root/.cache/node-gyp/14.17.6" 

将当前用户更改为root

参考docker镜像:

docker.io/giscafer/nodejs:1.0.0

FROM python:3.10.3
LABEL org.opencontainers.image.authors="Nicky"

RUN groupadd --gid 1000 pn && useradd --uid 1000 --gid pn --shell /bin/bash --create-home pn
ENV POETRY_HOME=/usr/local

# Install libpostal dependencies
RUN apt-get update && apt-get install -y \
    curl autoconf automake libtool pkg-config build-essential

# Java
RUN \
  wget https://javadl.oracle.com/webapps/download/GetFile/1.8.0_261-b12/a4634525489241b9a9e1aa73d9e118e6/linux-i586/jdk-8u261-linux-x64.tar.gz -O /opt/jdk-8u261-linux-x64.tar.gz \
  && tar -xzf /opt/jdk-8u261-linux-x64.tar.gz -C /opt \
  && rm /opt/jdk-8u261-linux-x64.tar.gz \
  && ln -s /opt/jdk1.8.0_261 /opt/jdk
ENV PATH $PATH:/opt/jdk/bin
ENV JAVA_HOME /opt/jdk
ENV _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true

# Node
RUN \
  wget -O /opt/node-v16.19.0-linux-x64.tar.gz https://nodejs.org/dist/v16.19.0/node-v16.19.0-linux-x64.tar.gz \
  && tar -xzf /opt/node-v16.19.0-linux-x64.tar.gz -C /opt \
  && rm /opt/node-v16.19.0-linux-x64.tar.gz \
  && ln -s /opt/node-v16.19.0-linux-x64 /opt/node
ENV PATH $PATH:/opt/node/bin


ENV USER=root

# Install node-gyp so node-postal works
RUN npm install -g node-gyp

RUN rm -rf /libpostal && \
    apt-get remove -y build-essential autoconf automake libtool curl && \
    apt-get autoremove -y && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*
© www.soinside.com 2019 - 2024. All rights reserved.