Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private npm registry #100

Open
bbohling opened this issue Jan 11, 2017 · 17 comments
Open

Private npm registry #100

bbohling opened this issue Jan 11, 2017 · 17 comments

Comments

@bbohling
Copy link

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
Copy link
Owner

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
Copy link

ChrisEbert commented Feb 15, 2017

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
Copy link

alexan commented Feb 23, 2017

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
Copy link

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

@sindresorhus sindresorhus changed the title Private NPM registry Private npm registry Jun 29, 2017
@alexan
Copy link

alexan commented Jul 12, 2017

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

@iMoses
Copy link

iMoses commented Jun 11, 2018

So.. any solutions here? :)

@alexan
Copy link

alexan commented Jun 13, 2018

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
Copy link

iMoses commented Jun 13, 2018

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

sindresorhus/latest-version#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
Copy link

huruji commented Dec 28, 2018

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
Copy link

yumitsu commented Jan 6, 2020

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

@StephanU
Copy link

StephanU commented May 7, 2020

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
Copy link

huruji commented Jul 9, 2020

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
Copy link

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

@joebnb
Copy link

joebnb commented Sep 29, 2020

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
Copy link

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
Copy link

huruji commented Nov 1, 2022

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
Copy link

banyaner commented Jan 6, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests