dividab / tsconfig-paths

Load node modules according to tsconfig paths, in run-time or via API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

loadConfig errors if paths property is missing

EarthlingDavey opened this issue · comments

const { absoluteBaseUrl, paths } = tsConfigPaths.loadConfig();

Results in:

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Object.getAbsoluteMappingEntries (/app/node_modules/tsconfig-paths/lib/mapping-entry.js:17:49)
    at Module.createMatchPath (/app/node_modules/tsconfig-paths/lib/match-path-sync.js:18:38)
    at file:///app/loader.js:9:29
    at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
    at async initializeLoader (node:internal/process/esm_loader:74:19)
    at async loadESM (node:internal/process/esm_loader:87:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)

I ran into this too; a simple workaround is to specify paths: {}, such as:

tsConfigPaths.register({
  baseUrl: 'dist',
  paths: {},
});