npm.commands.install error "node-pre-gyp spawn ENOENT"

(Lin Onetwo) #1

What I Wanted to Do

I’m installing packages programmatically inside electron. Code is as follow:

What Happened Instead

error “node-pre-gyp spawn ENOENT”

Reproduction Steps

  1. create a simple electron app
  2. use npm.commands.install(packagePath, packages, (err) => { to install for some dir, for example, packagePath can be ~/Desktop/somerepo, and package is ["sqlite3"] which needs node-pre-gyp

Details

I think npm.commands.install is not handling node-pre-gyp properly.

Platform Info

$ npm 6.9.0 in package.json
node: electron 5.0.1 Nodejs 12.0.0