sindresorhus / open

Open stuff like URLs, files, executables. Cross-platform.
MIT License
3.18k stars 218 forks source link

spawn cmd ENOENT #56

Open z354392349 opened 7 years ago

z354392349 commented 7 years ago

I am a novice, I do not know why it has been guaranteed wrong, it is troubled, and for a long time did not fix it, I hope you can help me, thank you very much. const opn = require('opn');

opn(' http://sindresorhus.com ');

kevva commented 7 years ago

Can you include a stack trace? And what OS are you using?

z354392349 commented 7 years ago

I'm glad to see your reply. I'm using the Windows10 64 bit system. Do you have any complete support for the current case? I'm a beginner. I hope I can get your help.

kevva commented 7 years ago

What does this give you?

opn('https://sindresorhus.com').catch(err => {
    console.log(err);
});
CroniD commented 7 years ago

Hi there,

I had a similar error in another context, but most likely the problem is caused by "child_process" of nodejs. There are some problems on windows platforms. E.g. consider a directory containing a bash Script and a windows shell script with the same name (bash script: xyz (without extension); shell script: xyz.cmd). Typing "xyz" in a windows shell will trigger the execution of "xyz.cmd" (".cmd" is implicitly added by the shell). "child_process" of nodejs doesn't do that. Therefore you will get the ENOENT error because it tries to actually execute the bash script.

An easy solution for me: https://github.com/IndigoUnited/node-cross-spawn

Maybe that will help.

Best regards

vrudkovskiy commented 7 years ago

Hi guys,

There was the same issue on our tester's computer(Win 8.1). Problem was caused by missing "%SystemRoot%\system32;" in PATH variable. That's why 'cmd' command was not visible if running program from mingw console.

brpaz commented 6 years ago

Similar error on Linux:

util.js:1022 Uncaught (in promise) Error: spawn /xdg-open ENOENT
    at exports._errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
nkpz commented 6 years ago

If you're having this issue on Linux and are using Webpack to package a node app, see https://github.com/webpack/webpack/issues/1599

hajimurtaza commented 5 years ago

What does this give you?

opn('https://sindresorhus.com').catch(err => {
    console.log(err);
});

ran this open("C:/Users/temp/AppData/Roaming/BitTorrent/BitTorrent.exe").catch(err =>{ console.log(err); })

Stack trace `C:\Users\temp\Real Work\resync-webpage Server is running at: 4000

uploading file events.js:183 throw er; // Unhandled 'error' event ^

Error: spawn cmd ENOENT at _errnoException (util.js:992:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19) at onErrorNT (internal/child_process.js:372:16) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! resync-webpage@1.0.0 start: node server.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the resync-webpage@1.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\temp\AppData\Roaming\npm-cache_logs\2019-06-14T22_22_58_740Z-debug.log`

talon266 commented 4 years ago

Is this going to be solved? I'm getting the same issue when %SystemRoot%\system32 isn't in the PATH variable.

sindresorhus commented 4 years ago

What does node -p 'process.env.ComSpec' output?

talon266 commented 4 years ago

My ComSpec variable is C:\WINDOWS\system32\cmd.exe

zaminhussain commented 4 years ago

hello ,,,i have face the same problem while use expo start commond using cmd ,,, so you should install gitbash to run app from there thanks

sindresorhus commented 4 years ago

I guess we could add path.dirname(process.env.ComSpec) to process.env.PATH.

oliversalzburg commented 3 years ago

Maybe this was fixed by #195 too?

chris-aeviator commented 3 years ago

running into this in a linux container?!

UPDATE:

for me the solution was to install the (normally standard) ps tool in my container