dividab / tsconfig-paths

Load node modules according to tsconfig paths, in run-time or via API.
MIT License
1.8k stars 100 forks source link

Importing folders starting with dot cause "Cannot find module" error #241

Open aczekajski opened 1 year ago

aczekajski commented 1 year ago

I have a folder .foo directly in project root with some modules in it.

Somewhere else in the project I do a non-relative import:

import { baz } from '.foo/bar';

In tsconfig I have set "baseUrl": ".", there are no paths and I added tsconfig-paths:

  "ts-node": {
    "files": true,
    "require": ["tsconfig-paths/register"],
  }

The tsc works fine, vscode can see that the import is correct (it was actually the autoimport in vscode that created the import). But when running with ts-node it fails with error:

Error: Cannot find module '.foo/bar'

Expected behavior: ts-node with tsconfig-paths registered should be able to import the module using non-relative import just as any other folder without a dot.

Additional info: