探索Electron API
我的目录:E:\resources\
Electron-github:https://github.com/electron/electron-api-demos
-
下载
$ git clone https://github.com/electron/electron-api-demos
-
进入目录
cd electron-api-demos
-
安装
npm install
发现
npm
不是内部命令(bash: npm: command not found) -
查资料发现安装
npm
之前需要先安装nvm
nvm-github下载nvm-setup.zip,解压运行exe文件
-
重启cmd
-
输入命令记录以及反馈如下
Microsoft Windows [版本 10.0.17763.1577] (c) 2018 Microsoft Corporation。保留所有权利。 C:\Users\Nicklaus>nvm list No installations recognized. C:\Users\Nicklaus>nvm list available | CURRENT | LTS | OLD STABLE | OLD UNSTABLE | | ------- | ------- | ---------- | ------------ | | 15.3.0 | 14.15.1 | 0.12.18 | 0.11.16 | | 15.2.1 | 14.15.0 | 0.12.17 | 0.11.15 | | 15.2.0 | 12.20.0 | 0.12.16 | 0.11.14 | | 15.1.0 | 12.19.1 | 0.12.15 | 0.11.13 | | 15.0.1 | 12.19.0 | 0.12.14 | 0.11.12 | | 15.0.0 | 12.18.4 | 0.12.13 | 0.11.11 | | 14.14.0 | 12.18.3 | 0.12.12 | 0.11.10 | | 14.13.1 | 12.18.2 | 0.12.11 | 0.11.9 | | 14.13.0 | 12.18.1 | 0.12.10 | 0.11.8 | | 14.12.0 | 12.18.0 | 0.12.9 | 0.11.7 | | 14.11.0 | 12.17.0 | 0.12.8 | 0.11.6 | | 14.10.1 | 12.16.3 | 0.12.7 | 0.11.5 | | 14.10.0 | 12.16.2 | 0.12.6 | 0.11.4 | | 14.9.0 | 12.16.1 | 0.12.5 | 0.11.3 | | 14.8.0 | 12.16.0 | 0.12.4 | 0.11.2 | | 14.7.0 | 12.15.0 | 0.12.3 | 0.11.1 | | 14.6.0 | 12.14.1 | 0.12.2 | 0.11.0 | | 14.5.0 | 12.14.0 | 0.12.1 | 0.9.12 | | 14.4.0 | 12.13.1 | 0.12.0 | 0.9.11 | | 14.3.0 | 12.13.0 | 0.10.48 | 0.9.10 | This is a partial list. For a complete list, visit https://nodejs.org/download/release C:\Users\Nicklaus>nvm install 15.3.0 Downloading node.js version 15.3.0 (64-bit)... Error while downloading https://nodejs.org/dist/v15.3.0/win-x64//node.exe - read tcp 192.168.36.122:50254->104.20.23.46:443: wsarecv: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. Complete Could not retrieve https://nodejs.org/dist/index.json. Get https://nodejs.org/dist/index.json: read tcp 192.168.36.122:50259->104.20.23.46:443: wsarecv: An existing connection was forcibly closed by the remote host. C:\Users\Nicklaus>nvm ls 15.3.0 C:\Users\Nicklaus>nvm use v15.3.0 Now using node v15.3.0 (64-bit) C:\Users\Nicklaus>nvm ls 15.3.0 C:\Users\Nicklaus>nvm use v15.3.0 Now using node v15.3.0 (64-bit) C:\Users\Nicklaus>nvm ls 15.3.0 C:\Users\Nicklaus>node -v 拒绝访问。 C:\Users\Nicklaus>nvm use 15.3.0 Now using node v15.3.0 (64-bit) C:\Users\Nicklaus>nvm ls 15.3.0 C:\Users\Nicklaus>node -v 拒绝访问。 C:\Users\Nicklaus>nvm list available | CURRENT | LTS | OLD STABLE | OLD UNSTABLE | | ------- | ------- | ---------- | ------------ | | 15.3.0 | 14.15.1 | 0.12.18 | 0.11.16 | | 15.2.1 | 14.15.0 | 0.12.17 | 0.11.15 | | 15.2.0 | 12.20.0 | 0.12.16 | 0.11.14 | | 15.1.0 | 12.19.1 | 0.12.15 | 0.11.13 | | 15.0.1 | 12.19.0 | 0.12.14 | 0.11.12 | | 15.0.0 | 12.18.4 | 0.12.13 | 0.11.11 | | 14.14.0 | 12.18.3 | 0.12.12 | 0.11.10 | | 14.13.1 | 12.18.2 | 0.12.11 | 0.11.9 | | 14.13.0 | 12.18.1 | 0.12.10 | 0.11.8 | | 14.12.0 | 12.18.0 | 0.12.9 | 0.11.7 | | 14.11.0 | 12.17.0 | 0.12.8 | 0.11.6 | | 14.10.1 | 12.16.3 | 0.12.7 | 0.11.5 | | 14.10.0 | 12.16.2 | 0.12.6 | 0.11.4 | | 14.9.0 | 12.16.1 | 0.12.5 | 0.11.3 | | 14.8.0 | 12.16.0 | 0.12.4 | 0.11.2 | | 14.7.0 | 12.15.0 | 0.12.3 | 0.11.1 | | 14.6.0 | 12.14.1 | 0.12.2 | 0.11.0 | | 14.5.0 | 12.14.0 | 0.12.1 | 0.9.12 | | 14.4.0 | 12.13.1 | 0.12.0 | 0.9.11 | | 14.3.0 | 12.13.0 | 0.10.48 | 0.9.10 | This is a partial list. For a complete list, visit https://nodejs.org/download/release C:\Users\Nicklaus>nvm install 14.3.0 Downloading node.js version 14.3.0 (64-bit)... Complete Creating C:\Users\Nicklaus\AppData\Roaming\nvm\temp Downloading npm version 6.14.5... Complete Installing npm v6.14.5... Installation complete. If you want to use this version, type nvm use 14.3.0 C:\Users\Nicklaus>nvm use 14.3.0 Now using node v14.3.0 (64-bit) C:\Users\Nicklaus>nvm ls 15.3.0 * 14.3.0 (Currently using 64-bit executable) C:\Users\Nicklaus>E: E:\>cd E:\resources\electron-api-demos E:\resources\electron-api-demos>npm install > electron-chromedriver@3.0.0 install E:\resources\electron-api-demos\node_modules\electron-chromedriver > node ./download-chromedriver.js > husky@0.14.3 install E:\resources\electron-api-demos\node_modules\husky > node ./bin/install.js husky setting up Git hooks done > core-js@3.6.5 postinstall E:\resources\electron-api-demos\node_modules\global-agent\node_modules\core-js > node -e "try{require('./postinstall')}catch(e){}" Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library! The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: > https://opencollective.com/core-js > https://www.patreon.com/zloirock Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -) > electron@7.2.4 postinstall E:\resources\electron-api-demos\node_modules\electron > node install.js Downloading electron-v7.2.4-win32-x64.zip: [===================================================] 100% ETA: 0.0 seconds npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) added 952 packages from 1237 contributors and audited 955 packages in 585.994s 13 packages are looking for funding run `npm fund` for details found 33 vulnerabilities (31 low, 1 moderate, 1 high) run `npm audit fix` to fix them, or `npm audit` for details E:\resources\electron-api-demos>npm audit fix npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) added 1 package from 1 contributor, updated 10 packages and moved 1 package in 18.559s 13 packages are looking for funding run `npm fund` for details fixed 26 of 33 vulnerabilities in 955 scanned packages 3 vulnerabilities required manual review and could not be updated 3 package updates for 4 vulnerabilities involved breaking changes (use `npm audit fix --force` to install breaking changes; or refer to `npm audit` for steps to fix these manually) E:\resources\electron-api-demos>npm audit fix --force npm WARN using --force I sure hope you know what you are doing. npm WARN deprecated debug@4.2.0: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797) npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 > electron-chromedriver@11.0.0 install E:\resources\electron-api-demos\node_modules\electron-chromedriver > node ./download-chromedriver.js > spectron@13.0.0 postinstall E:\resources\electron-api-demos\node_modules\spectron > node lib/rpath-fix.js + spectron@13.0.0 + electron-packager@15.1.0 + mocha@8.2.1 added 185 packages from 205 contributors, removed 95 packages, updated 50 packages and moved 3 packages in 138.405s 41 packages are looking for funding run `npm fund` for details fixed 3 of 6 vulnerabilities in 956 scanned packages 3 vulnerabilities required manual review and could not be updated 3 package updates for 3 vulnerabilities involved breaking changes (installed due to `--force` option) E:\resources\electron-api-demos> E:\resources\electron-api-demos>npm start > electron-api-demos@2.0.2 start E:\resources\electron-api-demos > electron . (electron) 'getName function' is deprecated and will be removed. Please use 'name property' instead. [15:54:32.602] [info] update-electron-app config looks good; aborting updates since app is in development mode
运行结果如下: