本篇文章主要介紹Electron開(kāi)發(fā)環(huán)境的安裝,主要包括:VSCode開(kāi)發(fā)工具、NodeJS, Electron。本人所使用的環(huán)境為Mac Book Pro至耻, Monterey 12.1版本。
1. 安裝 VSCode
直接在官網(wǎng)下載安裝
截屏2022-01-26 上午10.38.14.png
2. 安裝 Nodejs
直接在官網(wǎng)下載安裝
截屏2022-01-26 上午10.21.42.png
下載安裝即可。驗(yàn)證安裝成功尘颓,可輸入以下命令走触。
node -v
v16.13.2
3. 安裝Electron
變更源命令:
npm config set ELECTRON_MIRROR https://npm.taobao.org/mirrors/electron/
安裝命令:
npm install -g electron
出現(xiàn)以下錯(cuò)誤提醒
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/electron
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/electron'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/electron'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/electron'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/leying/.npm/_logs/2022-01-26T02_04_55_383Z-debug.log
采用下面的命令,解決權(quán)限問(wèn)題疤苹。
sudo npm install -g electron --unsafe-perm=true --allow-root
檢驗(yàn)安裝是否成功的方法如下:
electron -v
v16.0.7
截屏2022-01-26 上午10.37.23.png
歡迎大家多提建議或意見(jiàn)互广。
最后更新:2022年1月31日