簡體   English   中英

雲構建 angular npm 運行拋出 package.json 錯誤

[英]Cloud build angular npm run throws package.json error

我正在嘗試通過 Cloud build 構建和部署 angular 應用程序,源代碼位於 Source Repository 中。 這是我的 yaml

steps:
- name: gcr.io/cloud-builders/npm
args:
- install
id: Install angular
entrypoint: yarn
- name: gcr.io/cloud-builders/npm
args:
- run
- build
- '--prod'
id: Create build
entrypoint: yarn

我也嘗試將較早的入口點設置為 npm。 每次我運行這個我都會出錯

BUILD

Starting Step #0 - "Install angular"
Step #0 - "Install angular": Already have image (with digest): gcr.io/cloud-builders/npm
Step #0 - "Install angular": yarn install v1.22.5
Step #0 - "Install angular": success Saved lockfile.
Step #1 - "Create build": error Couldn't find a package.json file in "/workspace"
Step #1 - "Create build": info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Finished Step #1 - "Create build"

ERROR
ERROR: build step 1 "gcr.io/cloud-builders/npm" failed: step exited with non-zero status: 1
error Couldn't find a package.json file in "/workspace"

我的 Angular 代碼有 package.json 但深度為 2(不確定是否需要此信息)。 如何修復此錯誤?

聽起來 Cloud Build 找不到package.json文件,因為它不在根目錄中。 您可以為您的 npm 腳本步驟提供一個dir字段,以便npm run將在您的 package 文件所在的位置運行。

例如,如果您的 package 文件位於/src目錄中,您希望您的步驟是:

steps:
- name: 'gcr.io/cloud-builders/npm'
  args: ['run', 'build']
  dir: 'src'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM