update-notifier icon indicating copy to clipboard operation
update-notifier copied to clipboard

Private npm registry

Open bbohling opened this issue 8 years ago • 17 comments

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.

bbohling avatar Jan 11 '17 01:01 bbohling

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.

sindresorhus avatar Feb 13 '17 14:02 sindresorhus

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();

ChrisEbert avatar Feb 15 '17 14:02 ChrisEbert

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

alexan avatar Feb 23 '17 14:02 alexan

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

TooTallNate avatar Mar 17 '17 22:03 TooTallNate

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

  • we are using a private repository secured with ssl cert and key
  • the module package-json which is used by latest-version does not use these properties from .npmrc

I will create an issue there

alexan avatar Jul 12 '17 15:07 alexan

So.. any solutions here? :)

iMoses avatar Jun 11 '18 13:06 iMoses

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.

alexan avatar Jun 13 '18 15:06 alexan

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?

iMoses avatar Jun 13 '18 16:06 iMoses

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

huruji avatar Dec 28 '18 12:12 huruji

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

yumitsu avatar Jan 06 '20 10:01 yumitsu

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.

StephanU avatar May 07 '20 21:05 StephanU

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}`,
})

huruji avatar Jul 09 '20 17:07 huruji

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

dawn-chu avatar Aug 18 '20 23:08 dawn-chu

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

joebnb avatar Sep 29 '20 03:09 joebnb

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 avatar Sep 26 '22 08:09 msalafia

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

huruji avatar Nov 01 '22 08:11 huruji

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

banyaner avatar Jan 06 '23 10:01 banyaner