Skip to content

tsp install ignores user .npmrc #11665

Closed

Description

Repro Steps

  1. create a user .npmrc pointing to an alternative package registry
  2. run "tsp install"

Expected: Respects user .npmrc
Actual: Ignores user .npmrc, tries to fetch from npmjs.org

Also appears to ignore NPM_CONFIG_REGISTRY env var:

% export NPM_CONFIG_REGISTRY=...     

% npx tsp install --debug                                              
trace cli.args: CLI args: { _: [ 'install' ], debug: true, pretty: true, '$0': 'tsp' }
Internal compiler error!
File issue at https://github.com/microsoft/typespec

[TypeError: fetch failed] {
  [cause]: Error: read ENOTCONN
      at TLSWrap.onStreamRead (node:internal/stream_base_commons:216:20) {
    errno: -57,
    code: 'ENOTCONN',
    syscall: 'read'
  }
}

Activity

  1. github-actions commented on Aug 14, 2026

    @github-actions
    Contributor

    🎯 Issue Triage

    tsp install does not respect the user-level .npmrc file, causing it to always fetch packages from the default npmjs.org registry instead of any configured alternative registry.

    Category: Bug
    Area: compiler:core

    ⚠️ No reproduction provided. A minimal repro would help diagnose this issue.

    🔍 Analysis
    • tsp install invokes npm under the hood to install TypeSpec dependencies. The issue is that the npm invocation may be ignoring the user-level ~/.npmrc or project-level .npmrc that specifies an alternative registry.
    • This affects users in corporate/private environments who must route npm traffic through an internal registry (e.g., Azure Artifacts, Verdaccio, Nexus).
    • Root cause is likely that tsp install either uses a hardcoded registry URL, passes --registry explicitly, or spawns npm in a way that bypasses the standard .npmrc lookup.
    • Affected component: packages/compiler — the tsp install CLI command implementation.
    📝 Suggested next steps
    • Locate the tsp install implementation in packages/compiler and check how npm is invoked
    • Verify whether a --registry flag or environment variable is being hardcoded
    • Ensure npm is invoked in a way that respects the user's .npmrc (e.g., do not override registry)
    • Add a test or note that validates .npmrc registry configuration is honored

    Generated by Agentic Triage

  2. timotheeguerin commented on Aug 27, 2026

    @timotheeguerin
    Member

    So the problem with respecting .npmrc and NPM_CONFIG_REGISTRY is that typespec is package manager agnostic. Doing a bit of research other packages managers do not usually respect the NPM_CONFIG_REGISTRY var and have their own. As for npmrc it is a bit more but yarn 2+ doesn't respect it either.

    In practice tsp install just install the configured package manager(similar to how corepack did it) and run the install command for it(delegating to its own install logic). So you should need the TYPESPEC_NPM_REGISTRY env + whatever package manager you use config but after that everything should work. I am a bit more reluctant to change that right now without any strong ask.

    Package manager User/project .npmrc registry NPM_CONFIG_REGISTRY
    npm 11 Yes Yes
    pnpm 10 Yes Yes
    pnpm 11+ Yes, for registry/auth No—use PNPM_CONFIG_REGISTRY
    Yarn Classic 1.x Yes Yes
    Yarn Modern 2+ No—uses .yarnrc.yml No—use YARN_NPM_REGISTRY_SERVER
    Bun Yes Yes; also supports BUN_CONFIG_REGISTRY
    Corepack bootstrap No No—uses COREPACK_NPM_REGISTRY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingcompiler:coreIssues for @typespec/compiler

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions