首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >npm在码头容器(RHEL8)中安装RHEL8失败

npm在码头容器(RHEL8)中安装RHEL8失败
EN

Stack Overflow用户
提问于 2020-09-21 02:00:15
回答 2查看 387关注 0票数 0

我需要基于RHEL 8构建一个容器,然后安装LoopBack和ApiConnect。

  • 使用RedHat EnterpriseLinux8

运行容器

代码语言:javascript
复制
docker run -it --name api-framework-rhel8 -v ~/api-framework-rhel8:/api-framework-rhel8 registry.access.redhat.com/ubi8/ubi:8.1 bash

  • 将Node.js (v12)安装到容器

代码语言:javascript
复制
curl -sL https://rpm.nodesource.com/setup_12.x | bash -

yum install -y nodejs

  • 安装开发工具以构建本机加载项

代码语言:javascript
复制
yum install gcc-c++ make

yum install python38

yum install python27

  • 使用alternativespython映射到python2 (或python3) --两者都尝试过,但在api-connect安装过程中都失败了。

代码语言:javascript
复制
alternatives --set python /usr/bin/python2

安装

  • LoopBack

代码语言:javascript
复制
npm install -g loopback-cli

安装ApiConnect

代码语言:javascript
复制
npm install -g --unsafe-perm=true --allow-root apiconnect

然而,错误消息失败(来自控制台,2组):

代码语言:javascript
复制
gyp: [Errno 2] No such file or directory while executing command '['python', './generate_build_id.py']' 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:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 4.19.76-linuxkit
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/apiconnect/node_modules/appmetrics
gyp ERR! node -v v12.18.4
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 

请注意,python2python3安装在/usr/bin下,可以从容器访问,但是不能调用python

控制台中的第二组错误:

代码语言:javascript
复制
Error: appmetrics@3.1.3 install: `node extract_all_binaries.js || node-gyp rebuild`
error code ELIFECYCLE
error errno 1
error appmetrics@3.1.3 install: `node extract_all_binaries.js || node-gyp rebuild`
error Exit status 1
error Failed at the appmetrics@3.1.3 install script.
error This is probably not a problem with npm. There is likely additional logging output above.
EN

回答 2

Stack Overflow用户

发布于 2020-09-26 02:33:38

我注意到您正在使用Node.js 12.x。apiconnect工具包只支持Node.js 10.x。

我尝试了你问题中的大部分步骤,但切换到Node 10,这似乎解决了问题。

此外,请确保安装python27并运行您刚才提到的alternatives --set python /usr/bin/python2

下面是我使用的完整Dockerfile:

代码语言:javascript
复制
FROM registry.access.redhat.com/ubi8/ubi:8.1

RUN yum update -y && \
    yum install -y python27 gcc-c++ make

RUN alternatives --set python /usr/bin/python2

RUN curl -sL https://rpm.nodesource.com/setup_10.x | bash - && \
    yum install -y nodejs

RUN npm i -g --unsafe-perm=true apiconnect

CMD ["bash"]
票数 0
EN

Stack Overflow用户

发布于 2020-10-06 10:32:19

此Node版本适用于我:not-v8.8.1

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63985278

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档