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

Does not recognize module-like names in node #125

Closed moltar closed 4 years ago

moltar commented 4 years ago
{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "container": ["./container"],
    }
  }
}

Then calling it like so:

import { container } from 'container'

This works fine with ts-node, but after compiling it, does not work with node.

Error: Cannot find module 'container'
moltar commented 4 years ago

Actually doesn't seem to work with any other mapping either.

Changed to:

    "paths": {
      "~/*": ["./*"],
    }

Now getting:

Error: Cannot find module '~/container'
moltar commented 4 years ago

Calling with:

node -r tsconfig-paths/register lib/index.js
moltar commented 4 years ago

Ok, I see that my issue is the same as #86