nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.46k stars 279 forks source link

windows 11 unknown spawn error error code -4094 #3819

Open justincando opened 2 years ago

justincando commented 2 years ago

Details

when running npx create-react-app my-app I get this error and it tells me to report this as a bug.

Node.js version

v16.14.2

Example code

npx create-react-app my-app

Operating system

windows 11

Scope

Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts with cra-template...

Aborting installation. Unexpected error. Please report it as a bug: Error: spawn UNKNOWN at ChildProcess.spawn (node:internal/child_process:413:11) at Object.spawn (node:child_process:700:9) at spawn (C:\Users\steel\AppData\Roaming\npm\node_modules\create-react-app\node_modules\cross-spawn\index.js:12:24) at C:\Users\steel\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:390:19 at new Promise () at install (C:\Users\steel\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:341:10) at C:\Users\steel\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:468:16 at processTicksAndRejections (node:internal/process/task_queues:96:5) { errno: -4094, code: 'UNKNOWN', syscall: 'spawn' }

Deleting generated file... package.json Deleting my-app/ from D:\testreact Done.

Module and version

Not applicable.

rilysh commented 2 years ago

It looks like the child process failed to spawn an application. Can you provide some more context, that gives some more information?

stefanO2602 commented 2 years ago

I have a similar problem when running unit tests with jest and the mongodb-memory-server package (https://github.com/nodkz/mongodb-memory-server).

When running a sample script starting the server (binaries fully downloaded, no local mongod instance running locally), I get a similar error like in the issue desription.

Node.js version v16.15.1

package.json { "devDependencies": { "nodemon": "^2.0.18", "ts-node": "^10.8.2", "typescript": "^4.7.4" }, "dependencies": { "mongodb-memory-server": "^8.7.2" }, "config": { "mongodbMemoryServer": { "debug": "1" } } }

Example code

import { MongoMemoryServer } from 'mongodb-memory-server';

(async () => {
    const mongod = await MongoMemoryServer.create();
    const uri = mongod.getUri();
    console.log('uri: ', uri);
    await mongod.stop();
})();

Log output

MongoMS:MongoMemoryServer Mongo[unknown]: _startUpInstance threw a Error: Error: spawn UNKNOWN at ChildProcess.spawn (node:internal/child_process:413:11) at spawn (node:child_process:700:9) at MongoInstance._launchMongod (C:\Users\user-name\Projects\testing\mongodb-memory-server\node_modules\mongodb-memory-server-core\src\util\MongoInstance.ts:443:31) at MongoInstance. (C:\Users\user-name\Projects\testing\mongodb-memory-server\node_modules\mongodb-memory-server-core\src\util\MongoInstance.ts:345:31) at Generator.next () at fulfilled (C:\Users\user-name\Projects\testing\mongodb-memory-server\node_modules\tslib\tslib.js:115:62) { errno: -4094, code: 'UNKNOWN', syscall: 'spawn' } +603ms MongoMS:MongoMemoryServer Mongo[unknown]: stop: Called .stop() method +10ms MongoMS:MongoMemoryServer Mongo[unknown]: stop: "instanceInfo" is not defined (never ran?) +0ms Error: spawn UNKNOWN at ChildProcess.spawn (node:internal/child_process:413:11) at spawn (node:child_process:700:9) at MongoInstance._launchMongod (C:\Users\user-name\Projects\testing\mongodb-memory-server\node_modules\mongodb-memory-server-core\src\util\MongoInstance.ts:443:31) at MongoInstance. (C:\Users\user-name\Projects\testing\mongodb-memory-server\node_modules\mongodb-memory-server-core\src\util\MongoInstance.ts:345:31) at Generator.next () at fulfilled (C:\Users\user-name\Projects\testing\mongodb-memory-server\node_modules\tslib\tslib.js:115:62) { errno: -4094, code: 'UNKNOWN', syscall: 'spawn' }

o0101 commented 1 year ago

Also seeing this on Parallels Windows 11

idodidodi commented 1 year ago

I have the same issue, one time when I tried to build an Electron app with --watch, and at the same time, when running a subprocess while building a Python app, it seemed like a local issue, maybe related to 'win error' 225

juleskreutzer commented 1 year ago

Has anyone been able to resolve their issue? We're running into a simular issue when running unit tests in our pipelines...

idodidodi commented 1 year ago

In my case, I was running the same commands for months and it worked perfectly fine. Suddenly it stopped working, and I received the spawn error message. My colleagues who were using the same code didn’t experience it.

The only thing the solved that issue was to format my PC.

On Wed, 3 May 2023 at 14:32 Jules Kreutzer @.***> wrote:

Has anyone been able to resolve their issue? We're running into a simular issue when running unit tests in our pipelines...

— Reply to this email directly, view it on GitHub https://github.com/nodejs/help/issues/3819#issuecomment-1532870867, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDUWPG7QFNBZ7FOEZBT27LXEI66VANCNFSM5S2FFQVA . You are receiving this because you commented.Message ID: @.***>

--

עידו

juleskreutzer commented 1 year ago

Thanks for the reply. We’re currently facing this issue in Azure Pipelines. Changing the vmImage used doesn’t have any effect. Local it works as expectedMet vriendelijke groet, Jules KreutzerOp 3 mei 2023 om 18:09 heeft Ido Ayal @.***> het volgende geschreven: In my case, I was running the same commands for months and it worked perfectly fine. Suddenly it stopped working, and I received the spawn error message. My colleagues who were using the same code didn’t experience it.

The only thing the solved that issue was to format my PC.

On Wed, 3 May 2023 at 14:32 Jules Kreutzer @.***> wrote:

Has anyone been able to resolve their issue? We're running into a simular issue when running unit tests in our pipelines...

— Reply to this email directly, view it on GitHub https://github.com/nodejs/help/issues/3819#issuecomment-1532870867, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDUWPG7QFNBZ7FOEZBT27LXEI66VANCNFSM5S2FFQVA . You are receiving this because you commented.Message ID: @.***>

--

עידו

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

pogiaron commented 7 months ago

I think a wrapper batch script may be missing. And the script tries to run a js file with execFileSync.

Let's consider these scripts:

log.js

#!/usr/bin/env node
console.log("log.js");

test.js

const { execFileSync  } = require('child_process');
const cmd = 'C:\\pathto\\log.js';  //on ubuntu '/pathto/log.js'
execFileSync(cmd, {stdio: 'inherit'});

if you run the test.js in Windows you will get this error: Error: spawnSync C:\pathto\log.js UNKNOWN

if you run the test.js on Unix-like platforms it will run

https://stackoverflow.com/a/33510581 https://stackoverflow.com/questions/37585966/node-modules-bin-package-cmd-file-in-node-js/44468968#44468968

RedYetiDev commented 2 months ago

Is this issue still occuring? If not, feel free to self-close.

JuniperBarry2rr commented 2 months ago

I never found a fix I just got a new computer

Beboz1 commented 1 month ago

I have the same problem even if I try npx electron . And npx nw . I need help help me

JuniperBarry2rr commented 1 month ago

I have the same problem even if I try npx electron . And npx nw . I need help help me

Kind of the fix for me was learning it was a bad install what I did was fully uninstall it then reinstalled it. That did not work so I factory restored my computer due to other issue that worked for me.

Just something corrupts for some reason...