0

I'm trying to set up a build pipeline on Bitbucket. I'm using a clean new Angular project. So far it looks like this

- step:
    name: build frontend
    caches:
      - node
    condition:
      changesets:
        includePaths:
          - "frontend/src/deguvino-portal/**"
    image: node:14.5.0
    script:
      - npm install
      - npm install -g @angular/cli          
      - npm install -g npm@latest
      - npm install -g @angular-devkit/build-angular
      - npm run build --prod --prefix ./frontend/src/deguvino-portal/

And it keeps failing on npm run build command with error

An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
Require stack:
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/index.js
- /usr/local/lib/node_modules/@angular/cli/models/architect-command.js
- /usr/local/lib/node_modules/@angular/cli/commands/build-impl.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/index.js
- /usr/local/lib/node_modules/@angular/cli/utilities/json-schema.js
- /usr/local/lib/node_modules/@angular/cli/models/command-runner.js
- /usr/local/lib/node_modules/@angular/cli/lib/cli/index.js
- /usr/local/lib/node_modules/@angular/cli/lib/init.js
- /usr/local/lib/node_modules/@angular/cli/bin/ng
See "/tmp/ng-nTDaRU/angular-errors.log" for further details.
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! deguvino-portal@0.0.0 build: `ng build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the deguvino-portal@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-07-10T14_51_37_386Z-debug.log

Any suggestions on how can I fix it? P.S. I'm using npm run build and not ng build because my sources are not in the root folder, but under frontend/src/deguvino-portal/ directory, and I did found a way to specify a directory for ng build.

Roman Borovets
  • 818
  • 12
  • 25

1 Answers1

0

All I had to do is to navigate to the root folder with - cd ./frontend/src/deguvino-portal, do the installation and build and then return back. Complete script:

 - step:
    name: build frontend
    caches:
      - node
    image: node:14.5.0
    script:        
      - cd ./frontend/src/deguvino-portal
      - npm install
      - npm run build-prod
      - apt-get update
      - apt-get install zip -y
      - cd ./dist/deguvino-portal
      - zip -r PublishOutputUI.zip .
      - pipe: microsoft/azure-web-apps-deploy:1.0.3
        variables:
         AZURE_APP_ID: $AZURE_APP_ID
         AZURE_PASSWORD: $AZURE_PASSWORD
         AZURE_TENANT_ID: $AZURE_TENANT_ID
         AZURE_RESOURCE_GROUP: '****'
         AZURE_APP_NAME: '*****'
         ZIP_FILE: 'PublishOutputUI.zip'
    artifacts: 
      - PublishOutputUI.zip
Roman Borovets
  • 818
  • 12
  • 25