'npm start not working in Electron project

After cloning the repo for a particular electron project, I ran npm install after deleting the existing node packages and then ran .\node_modules\.bin\electron-rebuild.cmd, as instructed in the readme file. This rebuilt successfully and I proceeded to run npm start. I was then met with the following error -

{ Error: spawn C:\WINDOWS\system32\cmd.exe ENOENT
    at _errnoException (util.js:1024: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)
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn C:\\WINDOWS\\system32\\cmd.exe',
  path: 'C:\\WINDOWS\\system32\\cmd.exe',
  spawnargs: [ '/d', '/s', '/c', '"ampy"' ],
  cmd: 'ampy' }
(node:15028) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): fails
(node:15028) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Things I have tried -

  • Have tried re-building the project with the .\node_modules\.bin\electron-rebuild.cmd command
  • Ran npm start directly in cmd instead of VS code terminal by openings cmd in admin mode assuming there was some permissions error. This also threw the exact same error.
  • Have also tried reinstalling node modules.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source