Configure npm registry via .npmrc
See original GitHub issueAffected Packages
pkg:@changesets/cli
Problem
Looks like we can only get the npm registry from packageJson.publishConfig
or process.env.npm_config_registry
when running npm info
. Is there a way to get npm registry from .npmrc
file?
Also, is npm_config_registry
safe to rely on? Because it’s not documented.
Proposed solution
Read npm registry
in the following priorities:
packages/my-package/packageJson.publishConfig
packages/my-package/.npmrc
root/.npmrc
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:13 (7 by maintainers)
Top Results From Across the Web
registry | npm Docs
npm is configured to use the npm public registry at https://registry.npmjs.org by default. Use of the npm public registry is subject to terms...
Read more >Configure Your NPM Registry Settings - Nono Martínez Alonso
Run the npm config list command to see what variables are set. If you run this in a project folder with an .npmrc...
Read more >using myproject/.npmrc with registry - Stack Overflow
UPDATE: It is possible to work around the problem (npm is tied to only one registry). First you have to add a scope...
Read more >Working with the npm registry - GitHub Docs
You can use an .npmrc file to configure the scope mapping for your project. In the .npmrc file, use the GitHub Packages URL...
Read more >Configuring Your .npmrc for an Optimal Node.js Environment
Or, you may be using Certified Modules as a custom npm registry. There's even a separate registry for Yarn, a topic that is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Mostly a note for me: I’ve done a quick test and it seems that
npm info
doesn’t respectpackageJson.publishConfig.registry
- which makes this very inconvenient for us because we can’t simply rely on callingnpm info
either way. Maybe we can use--registry
only whenpackageJson.publishConfig.registry
is defined and delegate figuring out the correct registry to npm in all other cases.My current thinking is that we should just avoid using
--registry
as much as possible and I will experiment with that. When done right it feels like it really should yield the best results without us reimplementing a whole bunch of stuff that is a little bit tricky to get 100% right from the startDo you simply refer to the NPM_TOKEN used by our GitHub action since we only set it up in
.npmrc
for the default registry or are you referring to a broader standard? in other words - IsNPM_TOKEN
used by npm itself anyhow?@hayes thank you once again for the detailed write up about this issue. This has helped me to understand the complexity involved here much better. I’m currently working on improving the compatibility with publishing using pnpm and yarn - when I land this work I will be looking into fixing this one as it’s a very important feature that is not working correctly right now. I have very limited time resources though - so it won’t happen over night, please bear with me 😉
I think this should get used any time you install OR publish a package from that scope
What you wrote above looks like it matches my understanding