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

Cannot override the registry when running nuxi module add xxx #451

Closed
DevDengChao opened this issue Jul 19, 2024 · 3 comments
Closed

Cannot override the registry when running nuxi module add xxx #451

DevDengChao opened this issue Jul 19, 2024 · 3 comments
Labels
duplicate This issue or pull request already exists

Comments

@DevDengChao
Copy link

I have some trouble connecting npm's default registry https://registry.npmjs.org when running nuxi module add xxxx, then I found nuxi is always using this registry instead of the registry user defined in npm config.

const pkg = await $fetch(
`https://registry.npmjs.org/${pkgName}/${pkgVersion}`,
)

@DevDengChao DevDengChao changed the title nuxi module add dose not respect npm config nuxi module add dose not respect npm config Jul 19, 2024
@DevDengChao DevDengChao changed the title nuxi module add dose not respect npm config nuxi module add does not respect npm config Jul 19, 2024
@DevDengChao
Copy link
Author

DevDengChao commented Jul 19, 2024

Suggested solutions:

  • Option 1: define an env variable to allow user fetch packages from another registry:
     const pkg = await $fetch( 
         `${ process.env.NUXI_REGISTRY || 'https://registry.npmjs.org' }/${pkgName}/${pkgVersion}`, 
      ) 
  • Option 2: define an arg, e.g: nuxi module add xxx --registry xxxx
  • Option 3: load registry from npm config like other cli:
    $ yarn config list
    yarn config v1.22.22
    info yarn config
    {
      ...
      registry: 'https://registry.yarnpkg.com',
      ...
    }
    info npm config
    {
      registry: 'https://registry.npmmirror.com/'
    }
    
     const pkg = await $fetch( 
         `${ getRegistry() }/${pkgName}/${pkgVersion}`, 
      ) 

@DevDengChao DevDengChao changed the title nuxi module add does not respect npm config Cannot override the registry when running nuxi module add xxx Jul 19, 2024
@atinux
Copy link
Member

atinux commented Jul 31, 2024

Is this related to the same error as #453 ? If so would the proxy fallback work for you too?

@DevDengChao
Copy link
Author

Is this related to the same error as #453 ? If so would the proxy fallback work for you too?

Yes, they are the same issue.

@atinux atinux closed this as not planned Won't fix, can't repro, duplicate, stale Aug 12, 2024
@atinux atinux added the duplicate This issue or pull request already exists label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants