Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitbucket Pipelines run npm fails

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
like image 734
basagabi Avatar asked Jun 29 '17 01:06

basagabi


2 Answers

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
like image 159
mazedlx Avatar answered Nov 12 '22 17:11

mazedlx


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
like image 5
nmanh Avatar answered Nov 12 '22 19:11

nmanh