yeoman / update-notifier

Update notifications for your CLI app
BSD 2-Clause "Simplified" License
1.76k stars 132 forks source link

Private npm registry #100

Open bbohling opened 7 years ago

bbohling commented 7 years ago

I am using v1.0.3 with a CLI utility that has been added to our private npm registry. The registry is defined both in my global (user) .npmrc and local CLI utility .npmrc but it is still coming back as undefined when I use:

const updateNotifier = require('update-notifier');
const pkg = require('./package.json');

// Checks for available update and returns an instance
const notifier = updateNotifier({pkg});

// Notify using the built-in convenience method
notifier.notify();

// `notifier.update` contains some useful info about the update
console.log(notifier.update);

Is there a step I am missing? Based on #32 I thought it should work with private registries. Maybe I'm wrong though.

sindresorhus commented 7 years ago

Should work yes, but never tested as I don't use a private npm registry. Happy to merge a PR for a fix if there's a problem, but you're pretty much on your own when using a private npm registry.

ChrisEbert commented 7 years ago

Did you probably missed the namespace for the private registry?

const updateNotifier = require('update-notifier');

updateNotifier({
    pkg: {
        name: '@myPrivateRegistry/my-package',
        version: '1.0.0'
    }
}).notify();
alexan commented 7 years ago

had the same option with a private repo configured in .npmrc even the example.js does not work with this setup.

I don't use scoping in this context. The registry is configured to return private and external packages within the same url

TooTallNate commented 7 years ago

I am having issues used a scoped Sinopia server as well (similar setup as @ChrisEbert from the looks of it).

alexan commented 7 years ago

I've debugged this issue. Here are my findings:

I will create an issue there

iMoses commented 6 years ago

So.. any solutions here? :)

alexan commented 6 years ago

nobody seems very interested in fixing this issue or providing suggestions for a fix. As we are not using a private repo anymore, I will not create any PRs.

iMoses commented 6 years ago

I checked the problem and the lack of support comes from the latest-version package, and they don't wanna add support..

https://github.com/sindresorhus/latest-version/issues/9

Question is, if I'll fork the package and will create an alternative, will I waste my time or will it be used?

huruji commented 5 years ago

I add .npmrc in my project,and it works in our company's registry.

Returns undefined may caused by cache, you can try setting the option updateCheckInterval to change how often to check for updates.

like this: image

  const notifier = updateNotifier({ pkg, updateCheckInterval: 1 })
yumitsu commented 4 years ago

I suddenly faced the same problem, but as @huruji said - .npmrc with registry entry solved it.

StephanU commented 4 years ago

Same problem for me. This module wouldn't show updates from my private repository (Nexus).

The reason why it did not work was hidden in the outputs of the spawned process to request the npm registry. Changing this line: https://github.com/yeoman/update-notifier/blob/71a3f197c46ba8e82fd5c00bcc6ccf88f437de9f/index.js#L99 to 'inherit' revealed the problem:

GotError [RequestError]: self signed certificate

I was using https with a self signed certificate to access my private repository. The quick (and insecure) solution was to add

process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

before calling updateNotifier.

huruji commented 4 years ago

I forked this repo, and add registryUrl param to specify private npm registry, just see https://www.npmjs.com/package/update-notifier2

const updateNotifier = require('update-notifier2');

updateNotifier({
  pkg,
  registryUrl: 'http://npm.example.com',
}).notify({
  installCommand: `cnpm i -g ${pkg.name} --registry=${registryUrl}`,
})
dawn-chu commented 4 years ago

Hi, We have the same issue here that the private registry not working, is there any solutions?

joebnb commented 3 years ago

I forked this repo, and add registryUrl param to specify private npm registry, just see https://www.npmjs.com/package/update-notifier2

const updateNotifier = require('update-notifier2');

updateNotifier({
  pkg,
  registryUrl: 'http://npm.example.com',
}).notify({
  installCommand: `cnpm i -g ${pkg.name} --registry=${registryUrl}`,
})

i think,custom config update registry should implement on main branch

msalafia commented 1 year ago

We are in 2022 and still not working with private repository even though some solution have been proposed in other forks. Am i missing something?

huruji commented 1 year ago

We are in 2022 and still not working with private repository even though some solution have been proposed in other forks. Am i missing something?

@msalafia use this https://www.npmjs.com/package/update-notifier2

banyaner commented 1 year ago

Use .npmrc can solve this. I solve this problem by check the source code。 It use "package-json" package 。 image this function supports two ways for setting reigstryUrl. use user's options or use .npmrc。"update-notifier" only support .npmrc