美文网首页
Electron找不到path.txt的解决方法

Electron找不到path.txt的解决方法

作者: 路过麦田 | 来源:发表于2016-10-14 08:12 被阅读987次

    Electron经常会发神经,无缘无故遇到各种各样的问题,官网也在不断的更新,昨天就遇到了一个问题,本来好好的,在删掉了项目中的node_modules文件夹后,重新安装npm install,然后就出现了下面的问题:

    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)
    

    经过一番搜索,在万能的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那就生成一个好了,解决方法:

    cd node_modules/electron-prebuilt && node install.js
    

    重新运行,项目已经可以正常启动了。

    相关文章

      网友评论

          本文标题:Electron找不到path.txt的解决方法

          本文链接:https://www.haomeiwen.com/subject/yrhgyttx.html