我目前正在开发一个运行在电子(前原子壳)上的应用程序,并试图设计一种方法,在新的更新可用时提醒用户。要做到这一点,我使用电子更新器的方式在电子更新器-样品中描述。我还将辛托邦配置为侦听http://localhost:4873/ (默认行为),并运行以下命令行:
npm config set registry "http://localhost:4873"我签入了.npmrc文件,注册中心被正确地设置为新的值。
我遇到的问题是,当我试图检查更新时,我会在控制台中得到以下错误消息:
{ HTTPError:响应代码404 (未找到) 消息:“响应代码404 (未找到)”, 代码:未定义, 主持人:‘registry.npmjs.org y.npmjs.org’, 主机名:‘hostname y.npmjs.org’, 方法:“获取”, 路径:‘/黑客-键盘-电子’, statusCode: 404, statusMessage:“找不到”}
因此,我相信我忘记了npm配置中的一些东西,这使得应用程序能够侦听npm的常规路径,而不是Sinopia服务器。问题是什么?
请在下面找到我使用的代码:
foobar-generator
├──应用程序
├──保龄球组件
├──bower.json
├──index.html
├──指数js
├──main.js
├───项目
├──节点模块
├──npm-调试器
├──package.json
├──自述。md
└──窦视
package.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);
});
});你们看到我可能忘记/做错什么了吗?
发布于 2015-10-26 15:34:43
通过阅读npmrc (npm help npmrc)的手册,我发现.npmrc文件并不是唯一的。通过按照我的方式配置注册表,我只更改了每个用户的.npmrc。但是在您的项目根目录中也应该有这样一个文件!您应该在这个注册表中配置要使用的注册表。在项目根目录中添加此文件解决了我面临的问题。
发布于 2016-02-25 08:05:59
您应该侦听错误事件。尝尝这个
updater.on('error', function (err) {
console.log(err);
});https://stackoverflow.com/questions/33307355
复制相似问题