electron 入门小白贴
electron 入门小白贴
electron demo 跑起来!
毕设准备是做个 跨平台的做题的客户端,打算用 electron 来弄。
然而今天折腾了半天才终于吧demo给跑起来了。经历了许多的问题,果真是应了那句“万事开头难啊”
先是吧官网的demo electron-quick-start 下载下来运行,官网说是只需要三部:
# Clone the Quick Start repository
$ git clone https://github.com/electron/electron-quick-start
# Go into the repository
$ cd electron-quick-start
# Install the dependencies and run
$ npm install && npm start
但是我第三部总是运行不了,开始的时候执行npm start
就停在这里了,半天没反应。进入 node_modules
目录的 electron 执行 node install.js 也不行。然后各种 electron,electron . 命令都试过,快要放弃了
➜ electron-quick-start git:(master) npm start
> electron-quick-start@1.0.0 start /Users/baidu/Downloads/bishe/electron-quick-start
> electron .
fs.js:584
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/Users/baidu/Downloads/bishe/electron-quick-start/node_modules/electron/path.txt'
at Error (native)
at Object.fs.openSync (fs.js:584:18)
at Object.fs.readFileSync (fs.js:431:33)
at Object.<anonymous> (/Users/baidu/Downloads/bishe/electron-quick-start/node_modules/electron/index.js:4:42)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
npm ERR! Darwin 15.5.0
npm ERR! argv "/Users/baidu/.nvm/versions/node/v5.5.0/bin/node" "/Users/baidu/.nvm/versions/node/v5.5.0/bin/npm" "start"
npm ERR! node v5.5.0
npm ERR! npm v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! electron-quick-start@1.0.0 start: `electron .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron-quick-start@1.0.0 start script 'electron .'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the electron-quick-start package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! electron .
npm ERR! You can get their info via:
npm ERR! npm owner ls electron-quick-start
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/baidu/Downloads/bishe/electron-quick-start/npm-debug.log
➜ electron-quick-start git:(master) electron .
fs.js:584
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/usr/local/lib/node_modules/electron/path.txt'
at Error (native)
at Object.fs.openSync (fs.js:584:18)
at Object.fs.readFileSync (fs.js:431:33)
at Object.<anonymous> (/usr/local/lib/node_modules/electron/index.js:4:42)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
最后发现直接执行 electron 的时候是全局的,然后 cnpm install electron --save-dev
局部执行就好了,我的个小心脏啊。