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

unable to make it work #253

Open adan-ea opened 1 year ago

adan-ea commented 1 year ago

Hi, I've looked at the examples, the documentation, the issues and nothing seemed to help. Sorry for the useless issue.. I tried different types of import like ./src/* ../src/* src/* No matter what I do, I end up with this : Promise {

Error: Cannot find module 'src/utils/Logger' Require stack: - C:\Users\user\Documents\project\dist\src\handlers\taskHandler.js - C:\Users\user\Documents\project\dist\index.js Here is some more context : Node: `v18.12.1` tsconfig-path: `v4.2.0` | tsc: `v4.9.4` | npm: `v9.8.1` the command : `tsc && node -r tsconfig-paths/register dist/index.js` tsconfig.json ```json { "compilerOptions": { /* Language and Environment */ "target": "es2021", /* Modules */ "module": "commonjs", "resolveJsonModule": true, "types": ["node"], /* Emit */ "sourceMap": false, "outDir": "dist", "baseUrl": ".", "paths": { "*": ["./src/*"], "client": ["./index"], "core/*": ["./src/modules/core/*"], "qotd/*": ["./src/modules/qotd/*"], "scheduledEvents/*": ["./src/modules/customEvents/*"], "tempVoice/*": ["./src/modules/tempVoice/*"], "twitchLive/*": ["./src/modules/twitchLive/*"] }, /* Interop Constraints */ "esModuleInterop": true, "forceConsistentCasingInFileNames": true, /* Type Checking */ "strict": true, "noImplicitAny": true, "strictNullChecks": true, "strictFunctionTypes": true, "strictPropertyInitialization": true, "noImplicitThis": true, "useUnknownInCatchVariables": true, "alwaysStrict": true, "noUnusedLocals": false, "exactOptionalPropertyTypes": false, "noImplicitReturns": false, "noImplicitOverride": true, /* Completeness */ "skipLibCheck": true }, "include": ["src/**/*.ts", "tsconfig.json", "index.ts"] } ``` My project tree : ```txt project ├── dist │ ├── index.js │ ├── src │ │ ├── client.js │ │ ├── handlers │ │ ├── models │ │ ├── modules │ │ │ ├── core │ │ │ ├── customEvents │ │ │ ├── qotd │ │ │ ├── tempVoice │ │ │ └── twitchLive │ │ ├── services │ │ └── utils │ │ ├── Logger.js │ └── tsconfig.json ├── index.ts ├── src │ ├── client.ts │ ├── handlers │ ├── models │ ├── modules │ │ ├── core │ │ ├── customEvents │ │ ├── qotd │ │ ├── tempVoice │ │ └── twitchLive │ ├── services │ └── utils │ ├── Logger.ts └── tsconfig.json ```
Fritiof commented 1 year ago

Don't know if it helps you but I do this and it works, not using the asterix:

{ "paths": { "@vegitables/tomato": ["../../packages/tomato/src"] } }

quantuminformation commented 12 months ago

no luck

image

works fine relatively or with normal tsx mode

sahilshahane commented 10 months ago

@quantuminformation Same here, tried everything, changed node version, removed node_modules. nothing works