Electron經(jīng)常會(huì)發(fā)神經(jīng),無(wú)緣無(wú)故遇到各種各樣的問(wèn)題,官網(wǎng)也在不斷的更新妖混,昨天就遇到了一個(gè)問(wèn)題,本來(lái)好好的轮洋,在刪掉了項(xiàng)目中的node_modules文件夾后制市,重新安裝npm install
,然后就出現(xiàn)了下面的問(wèn)題:
Error: ENOENT: no such file or directory, open '/Users/lu/Workbench/nodejs/flood/node_modules/electron-prebuilt/path.txt'
at Error (native)
at Object.fs.openSync (fs.js:640:18)
at Object.fs.readFileSync (fs.js:508:33)
at Object.<anonymous> (/Users/lu/Workbench/nodejs/flood/node_modules/electron-prebuilt/index.js:4:42)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
經(jīng)過(guò)一番搜索弊予,在萬(wàn)能的StackOverflow上找到了這樣的一段話:
path.txt is created at install time:
https://github.com/mafintosh/electron-prebuilt/blob/master/install.js#L32,install.js is executed using the postinstall hook of npm:
https://github.com/mafintosh/electron-prebuilt/blob/master/package.json#L11
If you don't have a path.txt it means your computer did not run the postinstall script, or it did run it but it never got the point where path.txt was created. To debug I would recommend trying to find out if this line gets executed, and if so what the value of the variables on this line are:
https://github.com/mafintosh/electron-prebuilt/blob/master/install.js#L32
既然找不到path.txt
那就生成一個(gè)好了祥楣,解決方法:
cd node_modules/electron-prebuilt && node install.js
重新運(yùn)行,項(xiàng)目已經(jīng)可以正常啟動(dòng)了汉柒。