0

我正在尝试将我的 angular-meteor 项目上传'ng build'到 S3 Bucket。

这是我的.yml文件

on:
  push:
    branches:
    - dev

jobs:
  build:

    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Setup meteor
      uses: meteorengineer/setup-meteor@v1
      with:
        meteor-release: '1.8.1'
    

    - name: Install Node.js
      uses: actions/setup-node@v1
      with:
        node-version: '10.x'

    - name: NG build Angular
      run: ng build --prod

    - name: Deploy to S3
      uses: jakejarvis/s3-sync-action@master
      with:
        args: --acl public-read --delete

      env:
        AWS_S3_BUCKET: ${{ secrets.DEV_AWS_S3_BUCKET }}
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        AWS_REGION: ${{ secrets.AWS_REGION }}
        SOURCE_DIR: 'browser'

运行此程序后,我将收到该NG build Angular部分的此错误​​消息

在此处输入图像描述

而不是运行, 我ng build --prod也尝试运行ng build — prod — aot,但我仍然收到相同的错误消息。ng build -- --prodnpm run build -- --prod

有谁知道如何解决这个问题?

4

2 回答 2

1

默认情况下,GitHub 运行器不会有ng/angular cli. 所以我们必须安装它。下面的代码应该为您完成这项工作。

on:
  push:
    branches:
    - dev

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Setup meteor
      uses: meteorengineer/setup-meteor@v1
      with:
        meteor-release: '1.8.1'
    - name: Install Node.js
      uses: actions/setup-node@v1
      with:
        node-version: '10.x'

    - name: Install Angular CLI
      run: npm install -g @angular/cli

    - name: NG build Angular
      run: ng build --prod
    - name: Deploy to S3
      uses: jakejarvis/s3-sync-action@master
      with:
        args: --acl public-read --delete
于 2021-08-01T18:38:52.490 回答
1

@angular/cli安装为devDependency,因此您必须使用:

- name: NG build Angular
  run: npx ng build --prod

或在 Angular 12+

- name: NG build Angular
  run: npx ng build --configuration production
于 2021-08-03T19:02:43.177 回答