-1

I have this react app, I need to deploy into a google cloud storage thru google cloud build, I'm trying to do it adding a cloudbuild.yaml and add some steps to run the npm

This is what I have:

steps:
  - name: bash
    script: |
      npm install --force
  - name: bash
    script: |
      npm run build
  - name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
    entrypoint: gcloud
    args:
      ["storage", "cp", "/dist/*", "gs://bucket"]
timeout: 1200s
options:
  logging: CLOUD_LOGGING_ONLY

but cloud build show me an error:

Step #0: script: line 2: npm: not found

Elmer A. Chacon
  • 75
  • 3
  • 11

2 Answers2

1

In your steps, you use name: bash, so you use a container with bash installed, and not NPM.

Use a container name "node:19" for instance to get a node/npm compliant container and be able to invoke NPM.

guillaume blaquiere
  • 66,369
  • 2
  • 47
  • 76
1

As mentioned in this documentation. Before you can build your application, you must ensure that all of your project's dependencies are installed from npm or yarn.

steps:
- name: node
  entrypoint: npm
  args: ['install']

If you've defined a test script in your package.json, you can configure Cloud Build to run the script by adding test to the args field:

steps:
- name: node
  entrypoint: npm
  args: ['install']
- name: node
  entrypoint: npm
  args: ['test']

You can also check this link and github thread

Sathi Aiswarya
  • 2,068
  • 2
  • 11