Reputation: 9912
I have installed electron and tried to run the simples hello world application but got this error
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
I already did the usual things suggested in questions like this here (so please don't mark this as "duplicate question": those answer don't work) I deleted node_modules and the problem is still there.
Investigating furthermore I discovered that the problem is in line 7 of file index.js
var fs = require('fs')
var path = require('path')
var pathFile = path.join(__dirname, 'path.txt')
function getElectronPath () {
if (fs.existsSync(pathFile)) { //<=====HERE!!!!!
var executablePath = fs.readFileSync(pathFile, 'utf-8')
if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath)
}
return path.join(__dirname, 'dist', executablePath)
} else {
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
}
}
module.exports = getElectronPath()
and yes, the file "path.txt" does not exist in the installation.
Is it possible by anychance that this is a problem of versions? I have had installed nodejs for quite a time and I just installed electron.
npm -v
5.5.1
node -v
v8.9.1
npm list --depth=0 -g
+-- [email protected]
I just realize that I cannot even execute `electron -v'. If this is the problem how can I uninstall node and electron to start over?
Upvotes: 3
Views: 4863
Reputation: 7292
Environment:
macOS version 10.15.5
Electron v9.1.2
Sometimes there is somethings wrong with the network of downloading of Electron.You must delete the node_modules/electron
directory and then run the following command:
ELECTRON_MIRROR="https://cdn.npm.taobao.org/dist/electron/" npm install electron
You can modify the ELECTRON_MIRROR
where you can access it.
Upvotes: 1
Reputation: 84
Please do the following steps in order to solve the problem:
electron.exe
in it.Upvotes: 2
Reputation: 3631
The reason seems to be a download problem of the package from the js installation script failing silently. If you encouter this problem, reinstalling electron will be of no help. rather use this workaround, it does the job.
Upvotes: 1
Reputation: 338
Make sure that you run this command after deleting the node_modules directory:
npm install
Upvotes: 1