与电子更新和Sinopia节点registrypath

我目前正在研究一个在Electron(former atom-shell)上运行的应用程序,并试图devise一种方法来在有新的更新可用时提醒用户。 为此,我使用电子 更新器样本中描述的方式使用电子 更新器 。 我还configuration了Sinopia在http://localhost:4873/ (默认行为)上侦听并运行这个命令行:
npm config set registry "http://localhost:4873"我检查了.npmrc文件,registry正确设置了新的值。
我遇到的问题是当我尝试检查更新时,我在控制台中得到此错误消息:

{[HTTPError:响应代码404(未find)]
消息:'响应码404(未find)',
代码:undefined,
主机:'registry.npmjs.org',
主机名:'registry.npmjs.org',
方法:'GET',
path:'/黑客键盘电子',
statusCode:404,
statusMessage:'Not Found'}

所以我相信我在npm的configuration中忘记了一些东西,这使得应用程序监听npm而不是Sinopia服务器的正常path。 问题是什么?
请在下面find我使用的代码:

foob​​ar的发电机
├──app
├── 凉亭组件
├──bower.json
├──index.html
├──索引。 JS
├──主。 JS
├──nbproject
├── 节点模块
├──npm-debug.log
├──package.json
├──自述。 MD
└──sinopia

的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); }); }); 

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

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

你应该听错误事件。 尝试这个

 updater.on('error', function (err) { console.log(err); });