2

我有以下内容bitbucket.pipelines.yml

image: python:3.5.1

pipelines:
  branches:
    master:
      - step:
          script:
            - apt-get update
            - apt-get install nodejs -y
            - npm install
            - npm run build
            - python get-pip.py
            - pip install boto3==1.3.0
            - python s3_upload.py io-master.fromthiscomesthat.co.uk dist io-master

安装节点后,构建尝试运行失败npm

+ npm install
bash: npm: command not found

我想这是因为npm不在路径中。或者其他的东西。我的 Ubuntu/UNIX 技能不是最好的。

如何将安装添加到路径?

更新

好的,经过大量的摆弄,我的 YAML 现在看起来像这样:

image: python:3.5.1

pipelines:
  branches:
    master:
      - step:
          script:
            - apt-get update
            - apt-get install lsb-release -y
            - curl --silent https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
            - VERSION=node_5.x
            - DISTRO="$(lsb-release -s -c)" # <--- error here
            - echo "deb https://deb.nodesource.com/$VERSION $DISTRO main" | tee /etc/apt/sources.list.d/nodesource.list
            - echo "deb-src https://deb.nodesource.com/$VERSION $DISTRO main" | tee -a /etc/apt/sources.list.d/nodesource.list
            - apt-get update
            - apt-get install nodejs -y
            - npm install
            - npm run build
            - python get-pip.py
            - pip install boto3==1.3.0
            - python s3_upload.py io-master.fromthiscomesthat.co.uk dist io-master

现在我有一个小问题。lsb-release即使安装程序正确安装,也找不到。这是路径问题吗?当我不知道它被安装到哪里时,我该如何执行它?很难调试,因为它在 Bitbucket 上的 docker 实例中运行。

4

1 回答 1

9

Ubuntu 在其默认存储库中包含一个可以使用的 Node.js 版本,但它仅包含节点二进制文件。如果要安装npm,可以键入:

apt-get install npm

但是,我建议您添加由 NodeSource 维护的 PPA(个人包存档)。这可能会比官方的 Ubuntu 存储库拥有更多最新版本的 Node.js。

您需要安装 PPA 才能访问其内容,然后您可以nodejs按照与上面相同的方式安装该软件包。

curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install nodejs

使用此选项,nodejs 包包含 nodejs 二进制文件以及 npm,因此您无需单独安装 npm。

于 2016-10-26T20:59:51.263 回答