Skip to content

feat(nodejs): bump pnpm version to 11.7.0 and support v11+ global bin layout - #6494

Merged
suztomo merged 7 commits into
googleapis:mainfrom
suztomo:bump-pnpm-11
Jun 23, 2026
Merged

suztomo merged 7 commits into
googleapis:mainfrom
suztomo:bump-pnpm-11

Conversation

@suztomo

@suztomo suztomo commented Jun 18, 2026 •

Copy link
Copy Markdown
Member

This PR bumps pnpm version to 11.7.0 and Node.js to 22 in the Dockerfile, and updates the Node.js tool installer to support pnpm v11+ global bin directory layout.

We assume pnpm v11 is used.

Changes

  • Dockerfile (pnpm & Node bump): Bumps NODEJS_PNPM_VERSION to 11.7.0 and NODEJS_NODE_VERSION to 22 in cmd/librarian/Dockerfile. Node 22 is required for pnpm v11.
  • Dockerfile (Build Fix): Sets PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS=true during the Docker image build (librarian install nodejs) to bypass interactive build approval prompts for dependencies (fixing [ERR_PNPM_IGNORED_BUILDS]).
    • Reference: Starting with pnpm v10, build scripts are blocked by default for security. See the pnpm v10.0.0 release notes for details on why this is needed.
  • PNPM_HOME Adjustment: Updates getPNPMEnv in internal/librarian/nodejs/install.go to use the parent directory of Node bin directory as PNPM_HOME (filepath.Dir(globalBin)). This ensures pnpm (which installs to PNPM_HOME/bin in v11+) places the binaries back in the Node bin directory, which is in PATH.

Scope Notes

  • The use of LIBRARIAN_INSTALL_DIR is outside the scope of this pull request. This pull request does not make it harder to use LIBRARIAN_INSTALL_DIR.

Fixes #6480

… layout

Bumps pnpm version to 11.7.0 in Dockerfile. Updates getPNPMEnv to use the parent directory of node bin directory as PNPM_HOME for pnpm v11+, ensuring global binaries are installed in the node bin directory. Also sets PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS=true to bypass interactive build approval prompts.
@suztomo
suztomo requested a review from a team as a code owner June 18, 2026 15:14
Simplifies getPNPMEnv by assuming pnpm v11+ is always used, removing the version detection helper functions.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the PNPM version to 11.7.0 and adjusts the environment configuration (such as dynamically setting PNPM_HOME and enabling PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS) to support PNPM v11+. Feedback is provided to improve the robustness of the version parsing logic in the newly added isV11OrGreater function.

I am having trouble creating individual review comments. Click here to see my feedback.

internal/librarian/nodejs/install.go (181-191)

medium

The len(parts) == 0 check is redundant because strings.Split with a non-empty separator like "." always returns a slice of at least length 1. However, when splitting a string that is expected to have a specific number of parts, we should use strings.SplitN and check the length of the resulting slice to prevent panics. Additionally, we can make the version parsing more robust by trimming any leading 'v' prefix before splitting.

func isV11OrGreater(version string) bool {
	version = strings.TrimPrefix(version, "v")
	parts := strings.SplitN(version, ".", 2)
	if len(parts) < 1 {
		return false
	}
	major, err := strconv.Atoi(parts[0])
	if err != nil {
		return false
	}
	return major >= 11
}
References
  1. When splitting a string that is expected to have a specific number of parts, use strings.SplitN and check the length of the resulting slice to prevent panics.

suztomo added 5 commits June 18, 2026 15:16
Removes PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS env var from getPNPMEnv and its assertion in tests, as it is deemed irrelevant.
Removes the specific PNPM_HOME value assertion from the test stub to keep it generic and consistent with other env var checks.
Simplifies PNPM_HOME to always use filepath.Dir(globalBin) without checking for 'bin' folder name. Reverts all changes to install_test.go to match upstream/main.
Adds a comment above PNPM_HOME calculation in getPNPMEnv referencing pnpm v11 release notes.
Bumps Node.js to 22 to satisfy pnpm v11 requirements. Sets PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS=true during docker build to allow dependency builds.
@JoeWang1127

Copy link
Copy Markdown
Contributor

Reference: Starting with pnpm v10, build scripts are blocked by default for security. See the pnpm v10.0.0 release notes for details on why this is needed.

The link is broken.

@suztomo

suztomo commented Jun 23, 2026

Copy link
Copy Markdown
Member Author

@suztomo
suztomo merged commit 1373628 into googleapis:main Jun 23, 2026
32 of 33 checks passed
@suztomo
suztomo deleted the bump-pnpm-11 branch June 23, 2026 20:34
haphungw pushed a commit to haphungw/librarian that referenced this pull request Jun 26, 2026
… layout (googleapis#6494)

This PR bumps `pnpm` version to `11.7.0` and `Node.js` to `22` in the
Dockerfile, and updates the Node.js tool installer to support `pnpm`
v11+ global bin directory layout.

We assume `pnpm` v11 is used.

### Changes
* **Dockerfile (pnpm & Node bump):** Bumps `NODEJS_PNPM_VERSION` to
`11.7.0` and `NODEJS_NODE_VERSION` to `22` in
`cmd/librarian/Dockerfile`. Node 22 is required for `pnpm` v11.
* **Dockerfile (Build Fix):** Sets
`PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS=true` during the Docker image
build (`librarian install nodejs`) to bypass interactive build approval
prompts for dependencies (fixing `[ERR_PNPM_IGNORED_BUILDS]`).
* *Reference:* Starting with pnpm v10, build scripts are blocked by
default for security. See the [pnpm v10.0.0 release
notes](https://github.com/pnpm/pnpm/releases/tag/v10.0.0) for details on
why this is needed.
* **PNPM_HOME Adjustment:** Updates `getPNPMEnv` in
`internal/librarian/nodejs/install.go` to use the parent directory of
Node bin directory as `PNPM_HOME` (`filepath.Dir(globalBin)`). This
ensures `pnpm` (which installs to `PNPM_HOME/bin` in v11+) places the
binaries back in the Node bin directory, which is in `PATH`.

### Scope Notes
* The use of `LIBRARIAN_INSTALL_DIR` is outside the scope of this pull
request. This pull request does not make it harder to use
`LIBRARIAN_INSTALL_DIR`.

Fixes googleapis#6480
JoeWang1127 added a commit that referenced this pull request Jun 29, 2026
The `node` and `pnpm` version are updated in
#6494, we should update
these versions in workflow.
JoeWang1127 pushed a commit that referenced this pull request Jun 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.23.0](v0.22.0...v0.23.0)
(2026-06-29)


### Features

* **internal/librarian/java:** add decamelize utility for README
generation
([#6538](#6538))
([a6d950a](a6d950a)),
closes [#6515](#6515)
* **internal/librarian/java:** Add JSpecify dep to proto module template
([#6564](#6564))
([660ab2b](660ab2b))
* **internal/librarian/java:** add production sample filter
([#6545](#6545))
([df213ec](df213ec)),
closes [#6515](#6515)
* **internal/librarian/java:** add README sample extraction helpers
([#6574](#6574))
([500ba22](500ba22)),
closes [#6515](#6515)
* **internal/librarian/java:** add title override extractor
([#6546](#6546))
([0986d6a](0986d6a)),
closes [#6515](#6515)
* **internal/librarian/python:** update gapic-generator to 1.36.0
([#6548](#6548))
([a0930f4](a0930f4))
* **nodejs:** bump pnpm version to 11.7.0 and support v11+ global bin
layout ([#6494](#6494))
([1373628](1373628)),
closes [#6480](#6480)
* **sidekick/rust:** track recording error info for discovery LROs
([#6304](#6304))
([feb2ef2](feb2ef2)),
closes [#6286](#6286)
* **sidekick/swift:** generate synthetic messages
([#6530](#6530))
([7303648](7303648))
* **sidekick/swift:** handle clashing names
([#6543](#6543))
([56bf365](56bf365))
* **sidekick/swift:** swap client vs. protocol
([#6566](#6566))
([14e186c](14e186c))


### Bug Fixes

* **internal/librarian:** gracefully handle nil defaults in
applyDefaults
([#6571](#6571))
([3ee938a](3ee938a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NodeJS: librarian install places the files in a bin/bin folder.

2 participants