Skip to content

tsconfig.paths alias is not resolved for JSON imports with with { type: "json" } #726

Description

@shekharsikku

Environment

  • @oxc-node/cli: v0.1.0
  • Node.js: v24.19.0
  • OS: Windows 11

Reproduction

src/index.ts

import configs from "#/configs/cfg.json" with { type: "json" };

console.log(configs);

tsconfig.json

{
  "compilerOptions": {
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "paths": {
      "#/*": ["./src/*"]
    }
  }
}

Project structure

src/
├── index.ts
└── configs/
    └── cfg.json

Expected behavior

oxnode should resolve #/configs/cfg.json using the tsconfig.json compilerOptions.paths configuration, just as it does for TypeScript imports without the JSON import attribute.

Actual behavior

Running:

oxnode src/index.ts

fails with:

node:internal/modules/run_main:107
    triggerUncaughtException(
    ^
TypeError [ERR_PACKAGE_IMPORT_NOT_DEFINED]: Package import specifier "#/configs/cfg.json" is not defined in package D:\Repositories\synchronous-chat\package.json imported from D:\Repositories\synchronous-chat\src\app.ts

This suggests that the #/configs/cfg.json specifier is reaching Node's native ESM resolver without being resolved through the tsconfig.paths configuration first.

Comparison

The same import works with:

tsx src/index.ts       → works
tsc -b                 → works
tsc-alias              → works
node dist/...           → works
oxnode src/index.ts    → fails

The JSON file itself does not appear to be the issue.

Additional observations

Removing the import attribute:

import configs from "#/configs/cfg.json";

makes the alias work with oxnode.

Alternatively, adding a corresponding imports mapping to package.json also makes it work.

For example:

{
  "imports": {
    "#/*": "./src/*"
  }
}

This suggests that when with { type: "json" } is present, the tsconfig.paths resolver may be bypassed and the specifier is instead passed directly to Node's native package-import resolution.

Expected

This should work without requiring a corresponding package.json#imports entry:

import configs from "#/configs/cfg.json" with { type: "json" };

when the alias is defined through:

{
  "compilerOptions": {
    "paths": {
      "#/*": ["./src/*"]
    }
  }
}

Could this be related to the handling of import attributes in the resolver hook?

Activity

  1. added a commit that references this issue on Sep 11, 2026
    5769793
  2. added a commit that references this issue on Sep 12, 2026
    be799a4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions