Skip to content

[Bug]: http-client-csharp relies on NPM hoisting behavior #10802

@ascott18

Description

@ascott18

Describe the bug

Installing packages with pnpm v11 with enableGlobalVirtualStore: true results in the following issues due to undeclared dependencies in Typespec's package.json files:

@typespec/http-client-csharp has undeclared dependency on @azure-tools/typespec-azure-core

$ pnpm --dir typespec exec tsp compile .
TypeSpec compiler v1.12.0

× Compiling
Diagnostics were reported during compilation:

error js-error: Failed to load D:/.pnpm-store/v11/links/@typespec/http-client-csharp/1.0.0-alpha.20260521.5/aac8d44bffe0a214616303272337d1a59a3706494728983f23fcaec0feda23b2/node_modules/@typespec/http-client-csharp/dist/emitter/src/index.js due to the following JS error: Cannot find package '@azure-tools/typespec-azure-core' imported from D:\.pnpm-store\v11\links\@typespec\http-client-csharp\1.0.0-alpha.20260521.5\aac8d44bffe0a214616303272337d1a59a3706494728983f23fcaec0feda23b2\node_modules\@typespec\http-client-csharp\dist\emitter\src\type\operation-final-state-via.js
Did you mean to import "@azure-tools/typespec-azure-core/dist/src/index.js"?

Found 1 error.

@azure-tools/typespec-azure-core has undeclared dependency on @typespec/versioning

$ pnpm --dir typespec exec tsp compile .
TypeSpec compiler v1.12.0

× Compiling
Diagnostics were reported during compilation:

error js-error: Failed to load D:/.pnpm-store/v11/links/@typespec/http-client-csharp/1.0.0-alpha.20260518.6/9fa168bf69d3ecf1dc8bd5eb38e6c7c9be586b3e1d1c239f299a9bdba77df5cd/node_modules/@typespec/http-client-csharp/dist/emitter/src/index.js due to the following JS error: Cannot find package '@typespec/versioning' imported from D:\.pnpm-store\v11\links\@azure-tools\typespec-azure-core\0.68.0\bab52293e26dd81b1928d49e8e2dcb9748ba2fa13ac81adaa31dfa2c4bb7ca5b\node_modules\@azure-tools\typespec-azure-core\dist\src\decorators\preview-version.js
Did you mean to import "@typespec/versioning/dist/src/index.js"?

Found 1 error.

Workaround, via pnpm-workspace.yaml:

packageExtensions:
  "@typespec/http-client-csharp":
    dependencies:
      "@azure-tools/typespec-azure-core": "*"
  "@azure-tools/typespec-azure-core":
    dependencies:
      "@typespec/versioning": "*"

Reproduction

package.json:

{
  "name": "backend-api",
  "version": "0.1.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "@typespec/compiler": "latest",
    "@typespec/http": "latest",
    "@typespec/openapi3": "latest",
    "@typespec/http-client-csharp": "latest"
  }
}

pnpm-workspace.yaml:

enableGlobalVirtualStore: true

Then,

pnpm i
pnpm exec tsp compile .

Checklist

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingemitter:client:csharpIssue for the C# client emitter: @typespec/http-client-csharp

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions