Skip to content

bug: 10.45.3 has a broken package.json file #7078

@nbarnett

Description

@nbarnett

Provide environment information

  System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M4
    Memory: 173.75 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.21.1 - /Users/nbarnett/n/bin/node
    Yarn: 4.9.1 - /Users/nbarnett/project/node_modules/.bin/yarn
    npm: 10.9.4 - /Users/nbarnett/n/bin/npm
    bun: 1.2.17 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 143.0.7499.170
    Firefox: 145.0
    Safari: 18.5
  npmPackages:
    typescript: ~5.9.2 => 5.8.3 

Describe the bug

I get the following error trying to bundle my project containing @trpc/server 10.45.3:

Error: While trying to resolve module `@trpc/server/shared` from file `/Users/nbarnett/project/node_modules/@trpc/client/dist/index.mjs`, the package `/Users/nbarnett/project/node_modules/@trpc/server/shared/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/nbarnett/project/node_modules/@trpc/server/dist/shared.mjs`.

I note that the file @trpc/server/shared/package.json exists in 10.45.3 but did not exist in 10.45.2. The contents of this file is:

{"main":"../dist/shared.cjs","module":"../dist/shared.mjs","types":"../dist/shared.d.cts"}

However, none of these files exist, resulting in the observed error. The correct files are listed in the ./shared export in the top level package.json file, as they were in 10.45.2:

"./shared": {
  "import": "./dist/shared/index.mjs",
  "require": "./dist/shared/index.js",
  "default": "./dist/shared/index.js"
}

Patching the package to remove this additional package.json file resolves the error.

Link to reproduction

N/A

To reproduce

N/A

Additional information

No response

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd be down to file a PR fixing this bug!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions