How to use PNPM with Google Cloud Build?
Asked Answered
S

4

9

I'd like to migrate to PNPM, however, I can't find a way to use its lockfile on Google Cloud. My current cloudbuild config is the following:

steps:
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk:latest"
  entrypoint: 'gcloud'
  args: ["app", "deploy"]
timeout: "1600s"

Afaik these official images only support Yarn and NPM. Is there an easy way to replace Yarn with PNPM here?

I looked on the Cloud Builders GitHub repo, but there's no PNPM there either.

Supportable answered 1/8, 2020 at 14:44 Comment(0)
S
4

IIUC the App Engine standard Node runtime(s) require that you use npm or yarn. PNPM is thus not user-definable when using standard.

https://cloud.google.com/appengine/docs/standard/nodejs/specifying-dependencies

If you want to use App Engine with a different package manager you could use flex and define a custom runtime. This essentially allows you to define a container image to deploy to App Engine and this may be anything that exposes an httpd on :8080.

Serene answered 1/8, 2020 at 18:16 Comment(1)
This answer is outdated, pnpm is now supportedEhrsam
C
0

You might be able to use pnpm install followed by npm shrinkwrap. I think gcloud deploy will ignore what's in node_modules in favor of package-lock.json but you could delete it.

npm i -g pnpm && pnpm i && npm shrinkwrap

That's npm shrinkwrap. There is pnpm shrinkwrap but that generates a pnpm-style lockfile.

Candiscandle answered 8/2, 2023 at 21:4 Comment(0)
A
0

You can use bash:

- id: Install pnpm
  name: 'node:20'
  script: |
    #!/usr/bin/env bash
    npm install --global [email protected]
    pnpm install
    pnpm test
Alumina answered 20/9, 2023 at 1:58 Comment(0)
J
0

Another method using bash as entrypoint with args

  - name: 'node:latest'
    entrypoint: 'bash'
    args: 
      - '-c'
      - |
        npm install -g pnpm &&
        pnpm install &&
        pnpm run build
Janka answered 29/2, 2024 at 16:34 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.