Node: Error: spawnSync /bin/sh ENOENT

Created on 16 Nov 2016  Â·  7Comments  Â·  Source: nodejs/node

let { execSync: exec } = require('child_process');
let os = require('os');

let tmp = os.tmpdir();

exec(`npm install --prefix ${tmp}`, {
        cwd: './',
    encoding: 'utf8',
    stdio: 'inherit'
});
child_process.js:531
    throw err;
    ^

Error: spawnSync /bin/sh ENOENT
    at exports._errnoException (util.js:1026:11)
    at spawnSync (child_process.js:466:20)
    at execSync (child_process.js:522:13)
    at Cache.installModules (/index.js:173:3)
    at Object.<anonymous> (/install.js:11:7)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
  • Version: v7.0.0
  • Platform: 3.10.8
  • Subsystem: Darwin (MacOS Sierra 10.12.1 (16B2555))
    Darwin local 16.1.0 Darwin Kernel Version 16.1.0: Thu Oct 13 21:26:57 PDT 2016; root:xnu-3789.21.3~60/RELEASE_X86_64 x86_64

Please read my another issue before

child_process

Most helpful comment

I encounter the same error message in a Debian server, and it was due to a typo in cwd option pass to exec: the directory where not existing.

Maybe the error message could be enhanced...

All 7 comments

  • Does /bin/sh exist on your system? Can you run /bin/sh -c ls manually in a shell?
  • Does that problem also occur when you try to exec programs than npm, e.g. ls?

Does /bin/sh exist on your system?
Can you run /bin/sh -c ls manually in a shell?

Yep

Does that problem also occur when you try to exec programs than npm, e.g. ls?

No and I haven't seen that before. It's reproduced only with npm install ... or I didn't see what you mean.... Can you provide an example?

Closing for lack of activity.
@monolithed we can reopen if you are still experiencing this issue.

I encounter the same error message in a Debian server, and it was due to a typo in cwd option pass to exec: the directory where not existing.

Maybe the error message could be enhanced...

Same here : directory didn't exist

See the feature request in #11520.

options.shell: trueï¼› perhaps can solved it

Was this page helpful?
0 / 5 - 0 ratings