畢設準備是作個 跨平臺的作題的客戶端,打算用 electron 來弄。
然而今天折騰了半天才終於吧demo給跑起來了。經歷了許多的問題,果然是應了那句「萬事開頭難啊」node
先是吧官網的demo electron-quick-start 下載下來運行,官網說是隻須要三部:git
# 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 . 命令都試過,快要放棄了github
➜ 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
局部執行就行了,個人個當心髒啊。npm