Electron and typescript "Cannot find module 'electron'"
The problem seems to lie in the way tsc
(and tsserver
) resoves modules by default.
To use use node.js-like algorithm you need to add "moduleResolution": "node"
to "compilerOptions"
section of tsconfig.json
.
Having the exact same issue here. It also affects code completion in the VS Code since it cannot find the "electron" module.
This happens because electron does not exist in the node_module folder.
If I do npm install electron --save-dev
, it fixes the issue.