Why does 'apt-get install nodejs -y' not install npm?
apt-get, bitbucket-pipelines, node.js, npm, ubuntu
Solution
Ubuntu contains a version of Node.js in its default repositories that can be used but it only includes the node binary. If you want to install `npm` you can do it by typing:
`apt-get install npm`
However, I recommend you to add the PPA (personal package archive) maintained by NodeSource. This will probably have more up-to-date versions of Node.js than the official Ubuntu repositories.
You need to install the PPA to get access to its contents, and then you can install the `nodejs` package in the same way that you did above.
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install nodejs
Using this option, the nodejs package contains the nodejs binary as well as npm, so you don't need to install npm separately.
Problem
I have the following `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 ``` Having installed node, the build then fails trying to run `npm`: ``` + npm install bash: npm: command not found ``` I imagine this is because `npm` is not in the path. Or something. My Ubuntu/UNIX skills are not the best. How can I add the install to the path? Update Ok, after a lot of fiddling my YAML now looks like this: ``` 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 ``` Now I have a smaller problem. `lsb-release` is not being found, even though the installer installs it correctly. Is this a path issue?; how can I execute this when I don't know where it's being installed to? It's difficult to debug because it's running in a docker instance on Bitbucket.