首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有电子更新器和sin胸的节点注册路径

带有电子更新器和sin胸的节点注册路径
EN

Stack Overflow用户
提问于 2015-10-23 16:35:17
回答 2查看 492关注 0票数 2

我目前正在开发一个运行在电子(前原子壳)上的应用程序,并试图设计一种方法,在新的更新可用时提醒用户。要做到这一点,我使用电子更新器的方式在电子更新器-样品中描述。我还将辛托邦配置为侦听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

代码语言:javascript
复制
{
    "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

代码语言:javascript
复制
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);
    });
});

你们看到我可能忘记/做错什么了吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-10-26 15:34:43

通过阅读npmrc (npm help npmrc)的手册,我发现.npmrc文件并不是唯一的。通过按照我的方式配置注册表,我只更改了每个用户的.npmrc。但是在您的项目根目录中也应该有这样一个文件!您应该在这个注册表中配置要使用的注册表。在项目根目录中添加此文件解决了我面临的问题。

票数 0
EN

Stack Overflow用户

发布于 2016-02-25 08:05:59

您应该侦听错误事件。尝尝这个

代码语言:javascript
复制
updater.on('error', function (err) {
    console.log(err);
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33307355

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档