Commit Graph

31 Commits

Author SHA1 Message Date
Zoltan Kochan
23eb4a6141 refactor(env): unify node version specifier parsing into parseNodeSpecifier in node.resolver (#10668)
* refactor(env): unify node version specifier parsing into parseNodeSpecifier in node.resolver

Move parseNodeSpecifier from @pnpm/plugin-commands-env to @pnpm/node.resolver and
replace the simpler parseEnvSpecifier with an enhanced version that supports all
Node.js version specifier formats: standalone release channels (nightly, rc, test,
v8-canary, release), well-known aliases (lts, latest), LTS codenames (argon, iron),
semver ranges (18, ^18), and channel/version combos (rc/18, nightly/latest).

* fix(env): address parseNodeSpecifier review feedback

- Remove overly strict release/X.Y.Z-only validation; release/latest,
  release/lts, and release/<range> are now accepted
- Validate unknown release channels (e.g. foo/18) with a clear error
  instead of letting them fall through to a confusing network failure
- Add test cases for release/latest, release/lts, and release/18
2026-02-22 14:34:02 +01:00
Zoltan Kochan
50fbecae7d refactor(env): pnpm env use now delegates to pnpm add --global (#10666)
This PR overhauls `pnpm env` use to route through pnpm's own install machinery instead of maintaining a parallel code path with manual symlink/shim/hardlink logic.

```
pnpm env use -g <version>
```

now runs:

```
pnpm add --global node@runtime:<version>
```

via `@pnpm/exec.pnpm-cli-runner`. All manual symlink, hardlink, and cmd-shim code in `envUse.ts` is gone (~1000 lines removed across the package).

### Changes

**npm and npx shims on all platforms**

Added `getNodeBinsForCurrentOS(platform)` to `@pnpm/constants`, returning a `Record<string, string>` with the correct relative paths for `node`, `npm`, and `npx` inside a Node.js distribution. `BinaryResolution.bin` is widened from `string` to `string | Record<string, string>` in `@pnpm/resolver-base` and `@pnpm/lockfile.types`, so the node resolver can set all three entries and pnpm's bin-linker creates shims for each automatically.

**Windows npm/npx fix**

`addFilesFromDir` was skipping root-level `node_modules/` (to avoid storing a package's own dependencies), which stripped the bundled `npm` from Node.js Windows zip archives. Added an `includeNodeModules` option and enabled it from the binary fetcher so Windows distributions keep their full contents.

**Removed subcommands**

`pnpm env add` and `pnpm env remove` are removed. `pnpm env use` handles both installing and activating a version. `pnpm env list` now always lists remote versions (the `--remote` flag is no longer required, though it is kept for backwards compatibility).

**musl support**

On Alpine Linux and other musl-based systems, the musl variant of Node.js is automatically downloaded from [unofficial-builds.nodejs.org](https://unofficial-builds.nodejs.org).
2026-02-22 12:06:34 +01:00
Zoltan Kochan
71de2b3f2b feat!: remove use-node-version CLI option and pnpm.executionEnv.nodeVersion manifest field (#10373) 2025-12-27 22:41:53 +01:00
Zoltan Kochan
55de886750 fix: env remove after symlink-dir update 2025-09-23 18:48:42 +02:00
Zoltan Kochan
3df6702bcb fix: update load-json-file, write-json-file, write-pkg 2025-08-28 11:37:38 +02:00
Zoltan Kochan
facd7656e8 refactor: always use extensions in relative imports (#9878) 2025-08-19 15:25:11 +02:00
Zoltan Kochan
1a07b8fc7c feat: install Node.js runtime as a dependency (#9755) 2025-07-19 15:11:40 +02:00
btea
b61ade33d8 fix: compatible with more node pre-release versions (#9292)
* fix: compatible with more node pre-release versions

* fix: match prerelease regex

* docs: remove changeset

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
2025-03-17 01:53:24 +01:00
chlorine
6248d4064b fix: invalid Node.js version in use-node-version should not break (#9285)
close #9276
2025-03-16 11:32:30 +01:00
btea
adb236f1a1 refactor: improve regexp (#9203) 2025-03-02 13:17:09 +01:00
Zoltan Kochan
39c53852ea fix: some commands should not fail if a different package manager is set in package.json (#8802)
close #7959
2024-11-25 10:13:23 +01:00
Zoltan Kochan
298e5dcafd feat!: create a separate directory in the store for index files (#8700) 2024-10-27 21:00:28 +01:00
Ardeshir Izadi
d04f7f2320 fix: don't download node, when wanted node version is running (#8673)
close #8391

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
2024-10-21 02:53:47 +02:00
btea
9797a1e889 refactor: remove useless parameters from the catch statement (#8583) 2024-09-29 12:08:48 +02:00
Khải
24ad47cfb8 refactor: replace array.reduce (#8537) 2024-09-18 04:41:35 +02:00
Khải
0ef168b77d feat: per-package node version (#8277)
close #6720
2024-07-13 14:08:57 +02:00
btea
aba2b5f913 fix(env): remove about node 16 info (#8097) 2024-05-19 02:18:12 +02:00
Khải
3cc4372941 refactor(env): return type annotations (#7912) 2024-04-13 00:18:49 +02:00
Zoltan Kochan
0564745b1d style: use unknown in try/catch (#7709) 2024-03-06 01:47:04 +01:00
Nacho Aldama
7733f3a943 feat: support scoped client certificates (#7626)
close #7427

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
2024-02-14 12:11:12 +01:00
Hyunbin
4d2923858a fix(env): --global related error messages (#7456) 2023-12-26 12:59:34 +01:00
Hyunbin
b9c7fb91f3 fix(env): unify Node.js related expressions (#7356) 2023-12-03 18:34:39 +01:00
Eric Kwoka
2e6915727d feat(env): allow installing and removing multiple NodeJS versions at once (#7155)
---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
2023-10-05 03:13:46 +03:00
Khải
66423df837 feat: clear error on invalid node version (#6916)
related to #6909
2023-08-10 01:38:06 +03:00
Zoltan Kochan
34724dd0f2 fix: env use should work on Windows (#6884)
close #6587
2023-07-31 11:39:50 +03:00
Zoltan Kochan
49b15ac2e3 fix(env): use hard links instead of symlinks on Windows (#6405)
close #4315
2023-04-16 20:57:14 +03:00
GreyXor
36ffbfcd4b fix: typo standalone (#6244) 2023-03-19 21:02:40 +02:00
Zoltan Kochan
ee61ca4cb7 style: update eslint (#6236) 2023-03-18 14:57:29 +02:00
Zoltan Kochan
e570adc101 fix(env): fail with a meaningful error when no pnpm home dir is found (#6134)
close #6095
close #3865
2023-02-26 05:39:44 +02:00
Zoltan Kochan
4700b095ec fix: pnpm env should print help 2022-12-23 16:09:55 +02:00
Zoltan Kochan
4ca53b0b50 refactor: group projects in different subdirectories (#5659) 2022-11-20 01:35:22 +02:00