Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: node-gyp install fails with latest node.js #212240

Closed
bpasero opened this issue May 8, 2024 · 5 comments
Closed

Windows: node-gyp install fails with latest node.js #212240

bpasero opened this issue May 8, 2024 · 5 comments
Assignees
Labels
engineering VS Code - Build / issue tracking / etc. windows VS Code on Windows issues
Milestone

Comments

@bpasero
Copy link
Member

bpasero commented May 8, 2024

This code needs shell: true to work in latest node.js versions:

const yarnResult = cp.spawnSync(yarn, ['install'], {
env: process.env,
cwd: path.join(__dirname, 'gyp'),
stdio: 'inherit'
});

But even adding it, fails for me with:

yarn install v1.22.22
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.17s.
node:child_process:929
    throw err;
    ^

<ref *1> Error: spawnSync C:\Users\benjpas\vscode\build\npm\gyp\node_modules\.bin\node-gyp.cmd EINVAL
    at Object.spawnSync (node:internal/child_process:1117:20)
    at spawnSync (node:child_process:876:24)
    at Object.execFileSync (node:child_process:919:15)
    at installHeaders (C:\Users\benjpas\vscode\build\npm\preinstall.js:119:20)
    at Object.<anonymous> (C:\Users\benjpas\vscode\build\npm\preinstall.js:53:3)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
  errno: -4071,
  code: 'EINVAL',
  syscall: 'spawnSync C:\\Users\\benjpas\\vscode\\build\\npm\\gyp\\node_modules\\.bin\\node-gyp.cmd',
  path: 'C:\\Users\\benjpas\\vscode\\build\\npm\\gyp\\node_modules\\.bin\\node-gyp.cmd',
  spawnargs: [ 'list' ],
  error: [Circular *1],
  status: null,
  signal: null,
  output: null,
  pid: 0,
  stdout: null,
  stderr: null
}

Node.js v18.20.2
@bpasero bpasero added bug Issue identified by VS Code Team member as probable bug windows VS Code on Windows issues labels May 8, 2024
@bpasero
Copy link
Member Author

bpasero commented May 8, 2024

Oh wow, this even goes way beyond:

PS C:\Users\benjpas\vscode> yarn
yarn install v1.22.22
$ node build/npm/preinstall.js
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "@microsoft/1ds-core-js > @microsoft/applicationinsights-core-js@2.8.15" has unmet peer dependency "tslib@*".
warning " > tsec@0.2.7" has unmet peer dependency "@bazel/bazelisk@>=1.7.5".
warning " > tsec@0.2.7" has unmet peer dependency "@bazel/concatjs@>=5.3.0".
[4/4] Building fresh packages...
[1/21] ⠠ @parcel/watcher
[2/21] ⠠ @vscode/policy-watcher
[3/21] ⠠ @vscode/windows-ca-certs
[4/21] ⠠ @vscode/ripgrep
error C:\Users\benjpas\vscode\node_modules\@parcel\watcher: Command failed.
Exit code: 1
Command: node-gyp-build
Arguments:
Directory: C:\Users\benjpas\vscode\node_modules\@parcel\watcher
Output:
node:internal/child_process:414
    throw errnoException(err, 'spawn');
    ^

Error: spawn EINVAL
    at ChildProcess.spawn (node:internal/child_process:414:11)
    at Object.spawn (node:child_process:761:9)
    at build (C:\Users\benjpas\vscode\node_modules\node-gyp-build\bin.js:29:8)
    at preinstall (C:\Users\benjpas\vscode\node_modules\node-gyp-build\bin.js:38:32)
    at Object.<anonymous> (C:\Users\benjpas\vscode\node_modules\node-gyp-build\bin.js:15:3)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
  errno: -4071,
  code: 'EINVAL',
  syscall: 'spawn'

@bpasero bpasero added engineering VS Code - Build / issue tracking / etc. and removed bug Issue identified by VS Code Team member as probable bug labels May 8, 2024
@bpasero
Copy link
Member Author

bpasero commented May 8, 2024

I think we should just throw early when we detect this unsupported version here:

if (!process.env['VSCODE_SKIP_NODE_VERSION_CHECK']) {
if (majorNodeVersion < 18 || (majorNodeVersion === 18 && minorNodeVersion < 15)) {
console.error('\x1b[1;31m*** Please use node.js versions >=18.15.x and <19.\x1b[0;0m');
err = true;
}
if (majorNodeVersion >= 19) {
console.warn('\x1b[1;31m*** Warning: Versions of node.js >= 19 have not been tested.\x1b[0;0m')
}
}

@deepak1556 deepak1556 added this to the May 2024 milestone May 8, 2024
@TobiasFaller
Copy link

I think we should just throw early when we detect this unsupported version here:

if (!process.env['VSCODE_SKIP_NODE_VERSION_CHECK']) {
if (majorNodeVersion < 18 || (majorNodeVersion === 18 && minorNodeVersion < 15)) {
console.error('\x1b[1;31m*** Please use node.js versions >=18.15.x and <19.\x1b[0;0m');
err = true;
}
if (majorNodeVersion >= 19) {
console.warn('\x1b[1;31m*** Warning: Versions of node.js >= 19 have not been tested.\x1b[0;0m')
}
}

The issue is present on latest Node.JS 20 LTS (v20.13.1) and latest Node.JS 18 LTS (v18.20.2).
Using Node.JS 18.14.2 and using VSCODE_SKIP_NODE_VERSION_CHECK resolved the issue for me.

@dbaeumer
Copy link
Member

I have a fix ready for this in branch: dbaeumer/mighty-silverfish-ivory

But want to first get @deepak1556 opinion as well.

@deepak1556
Copy link
Contributor

deepak1556 commented May 14, 2024

/fixedWith 0e1e8fe

Thanks @dbaeumer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engineering VS Code - Build / issue tracking / etc. windows VS Code on Windows issues
Projects
None yet
Development

No branches or pull requests

4 participants