naugtur / npm-audit-resolver

Apache License 2.0
121 stars 28 forks source link

Curious spawn error #24

Closed kensentor closed 4 years ago

kensentor commented 4 years ago

I set up check-audit to run in my CI setup (AWS CodeBuild) but am receiving a curious error:

> check-audit --production

>>>> npm audit --json --production
Error: spawn = /bin/bash ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn = /bin/bash',
  path: '= /bin/bash',
  spawnargs: [ '-c', 'npm audit --json --production' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! client@1.0.0 check-audit: `check-audit --production`
npm ERR! Exit status 2

It's being run inside an environment with Node v12 and NPM v6.13 (which is already running a bunch of Node commands) as part of a Bash script that is the CI process. I'm running it via npm run check-audit which aliases to node node_modules/.bin/check-audit --production.

naugtur commented 4 years ago

that's odd.. maybe it's somehow restricted and not allowed to spawn child processes?

kensentor commented 4 years ago

I wondered that too, but I can't find anything in the AWS docs that asserts this restriction exists. I only found a forum thread by someone saying that exec apparently works: https://forums.aws.amazon.com/thread.jspa?threadID=290406 . Running Jest, JSHint, etc. are all working.

I guess the spawn command comes from down in the audit-resolve-core package somewhere?

naugtur commented 4 years ago

spawn is called to actually run npm audit or yarn audit under the hood and parse it's output. that's the only API they have that's unlikely to change without warning.

afair Amazon is running their own build if node for functions, not sure about CI

kensentor commented 4 years ago

I'll take it up with AWS. The necessary /bin/bash is definitely there, the $PATH is definitely there and it includes the node modules, so I don't know what it's barking about unless AWS has some kind of restriction in place. Thanks for taking a look.