6

Trying to set up pipelines with Angular CLI and running into an issue when calling ng build.

pipelines:
   default:
     - step:
        script: # Modify the commands below to build your repository.
          - npm --version
          - npm install
          - ng build

angular-cli is a dev dependency in my package.json, but ng cannot be found.

bash: ng: command not found

What step did I miss or doing wrong? Thank-you

Thibs
  • 8,058
  • 13
  • 54
  • 85

5 Answers5

4

Looks like it had to be called from npm context. I ended up calling npm build and added the script for it in the package.json

"build": "ng build"
Thibs
  • 8,058
  • 13
  • 54
  • 85
4

After including npm build as suggested above, things seemed to run successfully but it did actually not do anything. I had to replace it with $(npm bin)/ng build in order to work.

Sᴀᴍ Onᴇᴌᴀ
  • 8,218
  • 8
  • 36
  • 58
3

It worked for me.

image: node:10

pipelines:
  default:
    - step:
        script:
          - npm install
          - npm install -g @angular/cli
          - ng build --prod
1

You have to call in the npm context Just like suggested above. In your package.json write a script:

"scripts": {
        "build": "ng build"
}

then you can have

pipelines:
  default:
    - step:
        script: # Modify the commands below to build your repository.
          - npm --version
          - npm install
          - npm build

which will run ng build

Dunedan
  • 7,848
  • 6
  • 42
  • 52
RolandP
  • 11
  • 1
-1

Angular CLI is not installed in your docker image.

Use this configuration:

image: trion/ng-cli # Any docker image from dokerhub with angular cli installed.

pipelines:
  default:
    - step:
        caches:
          - node
        script: # Modify the commands below to build your repository.
          - npm install
          - npm run build