11

I have configured a PHP image for my Bitbucket's Pipelines that runs scripts thru a YML file. I have a laravel repository and want to execute a build command.

Though the problem is that on my script, when it runs the npm install, it fails.

bash: npm: command not found

# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: php:7.1.1

pipelines:
  default:
    - step:
        caches:
          - composer
        script:
          - apt-get update && apt-get install -y unzip
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - composer install
          - npm install --global gulp-cli
          - npm install
          - gulp --production
basagabi
  • 4,900
  • 6
  • 38
  • 84

2 Answers2

14

This should help. It'll install Node v8 and NPM v5. Put it before npm install --global gulp-cli

script:
    - curl -sL https://deb.nodesource.com/setup_8.x | bash -
    - apt-get install -y nodejs
mazedlx
  • 1,405
  • 17
  • 24
5

Your Problem lies here:

You are using the

image: php:7.1.1 docker image.

Which does not contain nodejs and npm. As you can see here in the Dockerfile:

https://github.com/docker-library/php/blob/eadc27f12cfec58e270f8e37cd1b4ae9abcbb4eb/7.1/Dockerfile

You have multiple ways of solving your problem.

Either:

  • install the dependencies with the package manager as mentioned by @mazedlx

  • use another dockerimage containing npm and nodejs, like this one: https://hub.docker.com/r/_/node/

    • change image: php:7.1.1 with f.e. image: node:latest
nmanh
  • 325
  • 2
  • 14