简体   繁体   English

云构建 angular npm 运行抛出 package.json 错误

[英]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.

相关问题 Google Cloud Functions 错误:“找不到模块‘sharp’”,但它在我的 package.json 中 - Google Cloud Functions error: "Cannot find module 'sharp'" but it's in my package.json NPM 无法安装软件包,引用缺少 package.json - NPM cannot install packages, cites missing package.json Firebase CLI 部署错误:读取函数/包时出错。json - Firebase CLI deploy Error: There was an error reading functions/package.json 部署到云运行时出现云构建错误 - Cloud build error when deploying to cloud run SvelteKit:AWS CodeBuild 中的“npm run build”错误 - SvelteKit: 'npm run build' error in AWS CodeBuild 如何获得相对 package.json 依赖项以在 Windows 上使用 AWS 的 sam build 命令? - How do I get relative package.json dependencies to work with AWS's sam build command on Windows? GCP Cloud Build 突然无法从 Github Package 获取 npm package - GCP Cloud Build suddenly cannot fetch npm package from Github Package NodeJS Elastic Beanstalk 环境报错 Cannot find module 'node-linux-arm64/package.json' - NodeJS Elastic Beanstalk environment error Cannot find module 'node-linux-arm64/package.json' Google Cloud Run with Angular 通用监听端口错误 - Google Cloud Run with Angular Universal listening port error CORS GCP Cloud Run 后端 Flask 错误和 Angular - CORS Error in Flask Backend on GCP Cloud Run and Angular
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM