Skip to content

Conversation

@furrycoding
Copy link

@furrycoding furrycoding commented Mar 23, 2024

On Windows, running webpack with this plugin added results in the following log:

> webpack

🧐  Checking for wasm-pack...

ℹ️  Installing wasm-pack 

⚠️ could not install wasm-pack globally when using npm, you must have permission to do this
[webpack-cli] Error: spawn npm ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn npm',
  path: 'npm',
  spawnargs: [ 'install', '-g', 'wasm-pack' ]
}

This seems to be because, by default, spawn on Windows will only look for .exe or .com files (docs)
However, npm is actually a .cmd file(similar to a .bat, an equivaent of a Linux shell script)
This can be fixed in a cross-platform way by enabling the shell option in spawn

There was a previous PR #122 which fixed this problem, however, it was closed by the author on the same day without a reason

@travbid
Copy link

travbid commented May 25, 2024

I believe this pull request would also fix an EINVAL error (which is being silently swallowed) occuring when using newer versions of node, caused by https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2
Related: nodejs/node#52554

Error: spawn EINVAL
    at ChildProcess.spawn (node:internal/child_process:421:11)
    at spawn (node:child_process:761:9)
    at ...\node_modules\@wasm-tool\wasm-pack-plugin\plugin.js:250:19
    at new Promise (<anonymous>)
    at runProcess (...\node_modules\@wasm-tool\wasm-pack-plugin\plugin.js:248:12)
    at spawnWasmPack (...\node_modules\@wasm-tool\wasm-pack-plugin\plugin.js:243:12)
    at ...\node_modules\@wasm-tool\wasm-pack-plugin\plugin.js:189:24 {
  errno: -4071,
  code: 'EINVAL',
  syscall: 'spawn'
}

@magcius
Copy link

magcius commented Aug 1, 2024

Would it be possible for this fix to be merged? Since node v20.12.2, this plugin can't launch npm on Windows, causing silent build breakage all over. It's unfortunate that a security fix for node broke backwards compatibility, but that's the way it appears to be.

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.

3 participants