Skip to content

PNPM_HOME path containing node_modules causes tsc to fail emitting assets (TS Bug #28432) #202

@nikicat

Description

@nikicat

When using pnpm/action-setup, the action sets PNPM_HOME to a path that includes a node_modules directory (e.g., /home/runner/setup-pnpm/node_modules/.bin).

If a project runs tsc (TypeScript Compiler) while nested within this directory structure - which happens during certain pnpm lifecycle scripts or when pnpm is invoked from this path - tsc fails to emit non-code assets like *.json files.

This is caused by a long-standing, unresolved bug in TypeScript: Issue #28432: tsc fails to emit required files when run below node_modules.

TypeScript has a hard-coded heuristic that prevents it from emitting files if it detects node_modules anywhere in the absolute path. Because pnpm/action-setup installs pnpm into a path containing node_modules, it triggers this bug, leading to "works locally, fails in CI" scenarios where dist folders are missing critical JSON assets.
Steps to Reproduce

  • Use pnpm/action-setup in a GitHub Action.
  • Have a dependency TypeScript project that imports a JSON file: import data from './data.json' with { type: 'json' };.
  • This dependency should be built during install stage, for example by installing it as dependency with github:... source url.
  • Try to run pnpm install in dependent project.

Result: The command fails because .js files are created in dist/ of dependency, but .json files are missing.

Suggestion: change PNPM_HOME to something not containing node_modules

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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