[英]Why does 'apt-get install nodejs -y' not install npm?
我有以下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实例中。
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。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.