Make tsp install respect .npmrc configuration - #11666
Draft
catalinaperalta with Copilot wants to merge 3 commits into
Draft
Make tsp install respect .npmrc configuration#11666catalinaperalta with Copilot wants to merge 3 commits into
tsp install respect .npmrc configuration#11666catalinaperalta with Copilot wants to merge 3 commits into
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: catalinaperalta <9859037+catalinaperalta@users.noreply.github.com>
Co-authored-by: catalinaperalta <9859037+catalinaperalta@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix tsp install to respect user .npmrc settings
Make Aug 14, 2026
tsp install respect .npmrc configuration
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tsp installdownloads the package manager (npm) itself before delegating to it, but that download was hardcoded tohttps://registry.npmjs.organd ignored any.npmrc. Users pointing at an alternative or private registry sawtsp installreach out to npmjs.org and fail.npm config resolution
packages/compiler/src/package-manger/npmrc.tsresolves npm configuration in npm's precedence order: global config → user config (~/.npmrc, ornpm_config_userconfig) → closest project.npmrc(walking up, skippingnode_modules) →npm_config_*environment variables.${ENV_VAR}expansion, and case-insensitive keys.@scope:registry, withTYPESPEC_NPM_REGISTRYstill taking precedence) and auth headers for a URL from_authToken,_auth, orusername/_password, matched from the most to the least specific path prefix.Install flow
fetchPackageManifest/fetchLatestPackageManifestaccept{ registry, headers }, and both manifest and tarball requests now throw on non-2xx responses instead of failing later with an opaque JSON/stream error.installTypeSpecDependenciesresolves the registry + credentials for the directory being installed, uses them for the manifest and tarball, traces the registry in use, and surfaces failures as aninstall-package-manager-errordiagnostic rather than an internal compiler error.Credential scoping
Auth headers are always resolved from the URL being requested, so credentials are only sent to hosts they are configured for. Registry credentials are not reused for a tarball hosted on a different origin.
Tests
test/package-manager/npmrc.test.tscovers parsing, file precedence, scoped registries, env var expansion/overrides,node_modulesexclusion, and credential matching (parent-path prefixes, non-matching hosts, basic auth variants).npm-registry.test.tsgains coverage for the new options and error behavior.tsp installignores user.npmrc#11665