我有在 ubuntu docker 文件中安装 nodejs 10.x 版本的所有代码,但是当我使用 node -v 而不是最新版本时,它只列出了旧版本。 PFB dockerfile 了解更多
FROM selenium/node-chrome-x.x.x
RUN curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
RUN apt-get install nodejs
RUN sudo ln -s /usr/bin/nodejs /usr/local/bin/node
RUN node -v
预期产出
Node 版本 10.x
实际输出
Node 版本为 4.86
请让我们知道如何设置最新的 nodejs 版本并将其用于其他工具设置
最佳答案
我已经修改了您的 Dockerfile 并使用了您需要的图像。我必须安装一些依赖项,例如 curl
等等。我也只运行一个 RUN
创建较少中间层的命令:
FROM selenium/node-chrome:2.53.1
RUN sudo apt-get update &&\
sudo apt-get -y install curl &&\
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - &&\
sudo apt-get -y install nodejs &&\
sudo ln -s /usr/bin/nodejs /usr/local/bin/node
RUN node -v
输出是:
v10.16.0
关于node.js - 无法在 docker 容器中安装 Node 10.x 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56513514/