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

pnpm doesn't get packages from expected registry #7542

Closed
2 of 4 tasks
uiolee opened this issue Jan 19, 2024 · 8 comments
Closed
2 of 4 tasks

pnpm doesn't get packages from expected registry #7542

uiolee opened this issue Jan 19, 2024 · 8 comments

Comments

@uiolee
Copy link

uiolee commented Jan 19, 2024

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

8.14.1

Which area(s) of pnpm are affected? (leave empty if unsure)

CLI

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

reproduction sample: #7542 (comment)

  1. pnpm config set registry https://registry.npmjs.org/ [--location project] (default registry)
  2. pnpm init
  3. pnpm i eslint (or any other packages.)
  4. pnpm config set registry https://localhost:56341/ [--location project] (specify any registry you want)
  5. pnpm add a_packages
    (pnpm will try to download packages from npmjs instead of custom registry. It will get failed because the package doesn't exist in npmjs)

err

I am expected that pnpm should get packages from the custom registry instead of npmjs.com

Describe the Bug

after exec pnpm config set registry, pnpm add <pkg> doen't work as expected.

BTW: if you add, modify or delete packages in (dev)dependencies of packages.json, pnpm i get failed too.

BTW: this issue exist in monorepo too: if you add new packages to monorepo_worksplace(packages/*/) and run pnpm i, you will get failed too.

I guess it's related to node_modules/.modules.yaml, it keeps a registries item. Sometimes pnpm will update registries from .npmrc, but sometimes not. That's so weird, isn't it?

Expected Behavior

pnpm should get packages from the custom registry
pnpm should recognize the registry setting in .npmrc

Which Node.js version are you using?

v20.10.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

@weyert
Copy link
Contributor

weyert commented Jan 19, 2024

Did you add the config to point your scope to your private registry?

@uiolee
Copy link
Author

uiolee commented Jan 19, 2024

sure

@nachoaldamav
Copy link
Contributor

Can you try using using the .npmrc file? If it works this way it's a bug in pnpm config set.
https://pnpm.io/npmrc#registry--authentication-settings

@weyert
Copy link
Contributor

weyert commented Jan 19, 2024

Yeah, also seems like pnpm config set registry https://registry.npmjs.org/ seems to set it globally instead for the current directory 🤔 Not sure if that is caused by asdf

@uiolee
Copy link
Author

uiolee commented Jan 20, 2024

Yes. .npmrc is correct. but it seems pnpm doesn't follow .npmrc

use pnpm config set ... --location project will get the same issue.

1. default setting

$ pnpm config set registry https://registry.npmjs.org/

$ cat $HOME/.npmrc
strict-ssl=false
registry=https://registry.npmjs.org/

2. init project

$ pwd
/d/git/tmp

$ ls -a
.  ..

$ pnpm init
Wrote to D:\git\tmp\package.json

{
  "name": "tmp",
  "version": "0.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": ""
}

$ pnpm i eslint
Packages: +99
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 99, reused 99, downloaded 0, added 99, done

dependencies:
+ eslint 8.56.0

Done in 4.7s

3. switch registry

$ pnpm config set registry https://private.registry.cccom/

$ cat $HOME/.npmrc
strict-ssl=false
registry=https://private.registry.cccom/
$ pnpm add a_packages
 ERR_PNPM_FETCH_404  GET https://registry.npmjs.org/a_packages: Not Found - 404

I am expected that pnpm should get pkgs from the custom registry instead of npmjs.com


3. switch registry (project)

$ pnpm config set registry https://private.registry.cccom/ --location project

$ cat ./.npmrc
registry=https://private.registry.cccom/

$ pnpm add a_packages
 ERR_PNPM_FETCH_404  GET https://registry.npmjs.org/a_packages: Not Found - 404

err

I am expected that pnpm should get pkgs from the custom registry instead of npmjs.com

@uiolee uiolee changed the title pnpm download packages from wrong registry pnpm doesn't get packages from expected registry Jan 20, 2024
@zkochan
Copy link
Member

zkochan commented Jan 21, 2024

It was probably fixed by this: #7515

but not published yet.

@uiolee
Copy link
Author

uiolee commented Jan 22, 2024

It was probably fixed by this: #7515

but not published yet.

I test via pd in latest main, it works as expected.

pd

@uiolee uiolee closed this as completed Jan 22, 2024
@taoliujun
Copy link

same problem.

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

5 participants