You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a4b727f
Browse filesBrowse the repository at this point in the historyBrowse files
pnpm as a package manager, for example from `npm install -g pnpm`, works
4
+
next to this plugin. The conflict starts when pnpm also installs Node.js:
5
+
`pnpm runtime set node <version> -g` (or the deprecated
6
+
`pnpm env use --global <version>`) puts a second `node` into
7
+
`$PNPM_HOME/bin`. Only the `node` that comes first in `PATH` runs, and with
8
+
the shell setup pnpm writes that is pnpm's, whatever `vfox use` selected.
9
+
10
+
Observed with pnpm 12.14.0 and vfox 1.0.12 in bash on Ubuntu.
11
+
12
+
## Symptoms
13
+
14
+
-`vfox use nodejs@24.21.0` prints `Now using nodejs@24.21.0` and
15
+
`vfox current nodejs` agrees, but `node --version` prints the
16
+
pnpm-managed version. Global, session and project scope are all affected.
17
+
-`type -a node` lists `$PNPM_HOME/bin/node` before the vfox path.
18
+
- In a directory with `.nvmrc` or `.node-version`, `node` runs a copy pnpm
19
+
downloads on first use, even when vfox has that version installed.
20
+
-`npm install -g <pkg>` succeeds but the command is not found. pnpm's
21
+
runtime ships no npm, so vfox's `npm` runs on pnpm's `node` and installs
22
+
into pnpm's copy of Node.js under `$PNPM_HOME`.
23
+
24
+
## Why
25
+
26
+
1.`pnpm runtime set node -g` refuses to run until `$PNPM_HOME/bin` is on
27
+
`PATH` (`ERR_PNPM_GLOBAL_BIN_DIR_NOT_IN_PATH`). The fix it suggests,
28
+
`pnpm setup`, adds a block at the end of the shell rc file, below
29
+
`eval "$(vfox activate bash)"`, that prepends `$PNPM_HOME/bin` to `PATH`.
30
+
2. At every prompt `vfox env` keeps the `PATH` entries that come before its
31
+
first own path ahead of all SDK paths, so that an activated Python
32
+
virtualenv keeps priority. `$PNPM_HOME/bin` is such an entry.
33
+
3. That `node` is pnpm's shim: it runs pnpm's global Node.js, or the version
34
+
the current project pins through `devEngines.runtime`, `engines.runtime`,
35
+
`.node-version` or `.nvmrc`
36
+
([project-aware global bins](https://pnpm.io/global-packages#project-aware-global-bins)).
37
+
pnpm's `globalShims` setting and `PNPM_SHIM_BYPASS=1` only turn off the
38
+
project lookup; `node` still runs pnpm's global Node.js, not vfox's.
39
+
40
+
`vfox use nodejs@<version>` prints a note when a `node` sits ahead of vfox
41
+
this way, whichever tool put it there:
42
+
43
+
```text
44
+
Note: /home/user/.local/share/pnpm/bin/node comes before vfox in PATH, so `node` will not run nodejs@24.21.0. See https://github.com/version-fox/vfox-nodejs/blob/main/docs/pnpm.md
45
+
```
46
+
47
+
## Keeping vfox in charge of `node`
48
+
49
+
Remove the Node.js that pnpm installed globally. pnpm keeps working, since
50
+
`pnpm setup` copied it into `$PNPM_HOME`:
51
+
52
+
```sh
53
+
pnpm remove -g node
54
+
```
55
+
56
+
Activating vfox below pnpm's block in the rc file is not enough: pnpm's
57
+
block prepends `$PNPM_HOME/bin` again unless it already comes first, so
58
+
nested shells put pnpm's `node` back in front.
59
+
60
+
Projects that pin a runtime with `devEngines.runtime` keep it for scripts:
61
+
after `pnpm install`, `pnpm run` and `pnpm exec` use the pinned Node.js from
62
+
`node_modules/.bin`, while a bare `node` follows vfox.
63
+
64
+
To let pnpm manage Node.js instead, do not select `nodejs` with vfox in the
0 commit comments