#修改npm的配置文件让npm到另外的pacakge mirror站点去找package
npm config set registry https://registry.npm.taobao.org
二、解决electron安装,卡在install.js不动的问题
(node:40800) UnhandledPromiseRejectionWarning: RequestError: read ECONNRESET
1.选择项目文件夹
2.npm init
3.npm install electron --save-dev
4.npm --registry=https://registry.npm.taobao.org install
5.node install.js的时候ctrl+c取消,y确定
6.cd ./node_modules/electron
7.下载https://cdn.npm.taobao.org/dist/electron/7.0.0/electron-v7.0.0-win32-x64.zip并复制到上面的文件夹,重命名为electron.zip
此为64位win版本,如果是其他版本请进入https://cdn.npm.taobao.org/dist/electron/7.0.0页面选择下载
8.修改 ./node_modules/electron/install.js,如下:
#!/usr/bin/env node
const version = require(‘./package‘).version
const fs = require(‘fs‘)
const os = require(‘os‘)
const path = require(‘path‘)
const extract = require(‘extract-zip‘)
const platformPath = ‘electron.exe‘
const zipPath = "./electron.zip"
extractFile (zipPath)
// unzips and makes path.txt point at the correct executable
function extractFile (zipPath) {
extract(zipPath, { dir: path.join(__dirname, ‘dist‘) }, function (err) {
if (err) return onerror(err)
fs.writeFile(path.join(__dirname, ‘path.txt‘), platformPath, function (err) {
if (err) return onerror(err)
})
})
}
9../node_modules/electron目录下运行,node install.js
10.返回项目目录,安装完成,如果为github下的demo,可以在此运行npm run start测试