Skip to content

Commit

Permalink
fix: skip automatic download/install of Node.js versions in WebContai…
Browse files Browse the repository at this point in the history
…ner (#7478)

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
  • Loading branch information
kirjavascript and zkochan committed Jan 2, 2024
1 parent 19be6b7 commit 8d7ec24
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-seals-brake.md
@@ -0,0 +1,5 @@
---
"pnpm": patch
---

Don't install Node.js when use-node-version is set in a WebContainer [#7478](https://github.com/pnpm/pnpm/pull/7478).
3 changes: 2 additions & 1 deletion cspell.json
Expand Up @@ -251,11 +251,12 @@
"uuidv",
"valign",
"vuln",
"webcontainer",
"winst",
"wrappy",
"xmarw",
"zkochan",
"zoli",
"zoltan"
"zoltan"
]
}
12 changes: 8 additions & 4 deletions pnpm/src/main.ts
Expand Up @@ -10,7 +10,7 @@ import {
} from '@pnpm/config'
import { executionTimeLogger, scopeLogger } from '@pnpm/core-loggers'
import { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'
import { logger } from '@pnpm/logger'
import { globalWarn, logger } from '@pnpm/logger'
import { type ParsedCliArgs } from '@pnpm/parse-cli-args'
import { node } from '@pnpm/plugin-commands-env'
import { finishWorkers } from '@pnpm/worker'
Expand Down Expand Up @@ -271,9 +271,13 @@ export async function main (inputArgv: string[]) {
})

if (config.useNodeVersion != null) {
const nodePath = await node.getNodeBinDir(config)
config.extraBinPaths.push(nodePath)
config.nodeVersion = config.useNodeVersion
if ('webcontainer' in process.versions) {
globalWarn('Automatic installation of different Node.js versions is not supported in WebContainer')
} else {
const nodePath = await node.getNodeBinDir(config)
config.extraBinPaths.push(nodePath)
config.nodeVersion = config.useNodeVersion
}
}
let result = pnpmCmds[cmd ?? 'help'](
// TypeScript doesn't currently infer that the type of config
Expand Down

0 comments on commit 8d7ec24

Please sign in to comment.