[英]Cloud build angular npm run throws package.json error
I am trying to build and deploy angular app via Cloud build and source code is in Source Repository.我正在尝试通过 Cloud build 构建和部署 angular 应用程序,源代码位于 Source Repository 中。 This is my yaml
这是我的 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
I tried earlier entrypoint as npm as well.我也尝试将较早的入口点设置为 npm。 Everytime I run this I get error
每次我运行这个我都会出错
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"
My Angular code has package.json but at depth 2 (not sure if this info is needed).我的 Angular 代码有 package.json 但深度为 2(不确定是否需要此信息)。 How can this error be fixed?
如何修复此错误?
It sounds like Cloud Build cannot find that package.json
file because it isn't in the root.听起来 Cloud Build 找不到
package.json
文件,因为它不在根目录中。 You can provide your npm script step with a dir
field so that npm run
will run where your package file is.您可以为您的 npm 脚本步骤提供一个
dir
字段,以便npm run
将在您的 package 文件所在的位置运行。
For example, if your package file was in a /src
directory, you'd want your step to be:例如,如果您的 package 文件位于
/src
目录中,您希望您的步骤是:
steps:
- name: 'gcr.io/cloud-builders/npm'
args: ['run', 'build']
dir: 'src'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.