我目前正在开发一个在 Electron(以前的 atom-shell)上运行的应用程序,并试图设计一种在有新更新可用时提醒用户的方法。为此,我以electron-updater-sample中描述的方式使用电子更新器。我还将Sinopia配置为正在侦听(默认行为)并运行以下命令行:
我签入了文件,注册表已正确设置为新值。
我遇到的问题是当我尝试检查更新时,我在控制台中收到此错误消息: http://localhost:4873/
npm config set registry "http://localhost:4873".npmrc
{ [HTTPError:响应代码 404(未找到)]
消息:'响应代码 404(未找到)',
代码:未定义,
主机:'registry.npmjs.org',
主机名:'registry.npmjs.org',
方法: 'GET',
路径:'/hacker-keyboard-electron',状态码
:404,
状态消息:'未找到'}
所以我相信我在 npm 的配置中忘记了一些东西,它使应用程序监听 npm 的常规路径而不是 Sinopia 服务器。问题是什么?
请在下面找到我正在使用的代码:
foobar -generator
├── app
├── bower 组件
├── bower.json
├── index.html
├── index. js
├── 主要。js
├── nbproject
├──节点模块
├── npm-debug.log
├── package.json
├── 自述文件。md
└── sinopia
包.json
{
"name": "foobar-generator",
"version": "0.0.1",
"description": "A generator for foobar",
"main": "main.js",
"dependencies": {
"angular": "^1.4.7",
"bootstrap": "^3.3.5",
"chokidar": "^1.2.0",
"electron-debug": "^0.2.1",
"electron-packager": "^5.1.0",
"electron-plugins": "^0.0.4",
"electron-prebuilt": "^0.33.6",
"electron-rebuild": "^1.0.2",
"electron-updater": "^0.2.0",
"grunt": "^0.4.5",
"jquery": "^2.1.4"
},
"devDependencies": {},
"publishConfig": {
"registry": "http://localhost:4873/"
},
"registry": "http://localhost:4873/"
}
main.js
var appli = require('app');
var BrowserWindow = require('browser-window');
var updater = require('electron-updater');
var util = require('util');
// Report crashes to our server.
require('crash-reporter').start();
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null;
var loaded = false;
// Quit when all windows are closed.
appli.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
appli.quit();
}
});
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
appli.on('ready', function () {
updater.on('ready', function () {
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600});
// and load the index.html of the app.
mainWindow.loadUrl('file://' + __dirname + '/index.html');
mainWindow.openDevTools({detach: true});
mainWindow.on('closed', function () {
mainWindow = null;
});
});
updater.on('updateRequired', function () {
appli.quit();
});
updater.on('updateAvailable', function () {
if (mainWindow) {
mainWindow.webContents.send('update-available');
}
});
updater.start();
updater.check(function (err, results) {
if (err) {
return console.error(util.inspect(err));
}
console.log(results);
});
});
你们看到我可能忘记/做错了什么吗?