Angular Bitbucket Pipeline не может запустить сборку ng - PullRequest
0 голосов
/ 16 февраля 2020

Я создал конвейер для развертывания моего angular приложения на моем ftp-сервере через конвейер bitbucket. Поэтому я создал этот файл pipe.yml:

 image: node:6.9.4 # we need node image to run our angular application in 
  clone: # help to clone our source here
  depth: full
 pipelines: # We set up all the pipeline or actions beneath 
default: # here most always trigger before any other pipeline 
  - step:
      script:
        - echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'." 

branches: # This is branch specific configuration, we can set for different branches and different actions when we push codes
  master:
    - step:
        script: 
          - npm install -g @angular/cli 
          - npm install 
          - ng build --prod
          - echo "Let's go in to our dist/ and initialize there with git"
          - cd dist/ 
          - git config --global user.email "account@clate.de"
          - git config --global user.name "clate"
          - git init
          - git add -A && git commit -m "base url updated for prod deployment" 
          - git clone https://github.com/git-ftp/git-ftp.git
          - cd git-ftp 
          - git checkout 1.3.4
          - make install
          - echo "Done with installation of git-ftp"
          - cd ../
          - rm -rf git-ftp
          - git config git-ftp.url "ftp://188.40.30.32/test"
          - git config git-ftp.user $FTP_USERNAME
          - git config git-ftp.password $FTP_PASSWORD
          - git ftp push --auto-init

К сожалению, я получаю сообщение об ошибке при попытке выполнить команду ng build --prod Показывает эту ошибку:

+ ng build --prod
/usr/local/lib/node_modules/@angular/cli/bin/ng:23
 );
 ^
SyntaxError: Unexpected token )
  at Object.exports.runInThisContext (vm.js:76:16)
  at Module._compile (module.js:542:28)
  at Object.Module._extensions..js (module.js:579:10)
  at Module.load (module.js:487:32)
  at tryModuleLoad (module.js:446:12)
  at Function.Module._load (module.js:438:3)
  at Module.runMain (module.js:604:10)
  at run (bootstrap_node.js:394:7)
  at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3

i Я попытался запустить его локально, и он работает без проблем.

1 Ответ

1 голос
/ 16 февраля 2020

у вас установлено angular cli в вашем проекте, лучше и быстрее будет использовать локальную установку ng для сборки вашего проекта. просто добавьте скрипт npm и вызовите build через npm следующим образом:

//package.json
"scripts": {
 "build:prod": "ng build --prod",
...
}


pipeline.yml

       - npm install -g @angular/cli <---THIS IS NO LONGER NEEDED
       - npm install
       - npm run build:prod
....
...