By npm run I get Error: Cannot find module ‘@/common/logger’
VSC can recognise the paths and by typing in code it resolves correct
tsconfig.json
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"baseUrl": ".",
"paths": { "@/*": ["src/*"]},
"outDir": "./build",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules"
]
}
here error by npm run
Require stack:
- /Users/vikkes/hansetag/backend/user-admin/src/iam/orgs/orgs.service.ts
- /Users/vikkes/hansetag/backend/user-admin/src/iam/users/users.service.ts
- /Users/vikkes/hansetag/backend/user-admin/src/iam/users/users.router.ts
- /Users/vikkes/hansetag/backend/user-admin/src/server.ts
- /Users/vikkes/hansetag/backend/user-admin/src/index.ts
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/vikkes/hansetag/backend/user-admin/src/iam/orgs/orgs.service.ts:13:1)
at Module._compile (node:internal/modules/cjs/loader:1095:14)
at Module._compile (/Users/vikkes/hansetag/backend/user-admin/node_modules/source-map-support/source-map-support.js:568:25)
at Module.m._compile (/private/var/folders/zg/h0dstg4n2gn4cr908hw7jcdh0000gn/T/ts-node-dev-hook-20917609479276456.js:69:33)
at Module._extensions..js (node:internal/modules/cjs/loader:1147:10)
at require.extensions.<computed> (/private/var/folders/zg/h0dstg4n2gn4cr908hw7jcdh0000gn/T/ts-node-dev-hook-20917609479276456.js:71:20)
[ERROR] 09:45:16 Error: Cannot find module '@/common/logger'
Require stack:
- /Users/vikkes/hansetag/backend/user-admin/src/iam/orgs/orgs.service.ts
- /Users/vikkes/hansetag/backend/user-admin/src/iam/users/users.service.ts
- /Users/vikkes/hansetag/backend/user-admin/src/iam/users/users.router.ts
- /Users/vikkes/hansetag/backend/user-admin/src/server.ts
- /Users/vikkes/hansetag/backend/user-admin/src/index.ts
tsc –traceResolution shows that it resolves correct but still not able to start npm
======== Resolving module '@/common/logger' from '/Users/vikkes/hansetag/backend/user-admin/src/iam/orgs/orgs.service.ts'. ========
Module resolution kind is not specified, using 'NodeJs'.
'baseUrl' option is set to '/Users/vikkes/hansetag/backend/user-admin', using this value to resolve non-relative module name '@/common/logger'.
'paths' option is specified, looking for a pattern to match module name '@/common/logger'.
Module name '@/common/logger', matched pattern '@/*'.
Trying substitution 'src/*', candidate module location: 'src/common/logger'.
Loading module as file / folder, candidate module location '/Users/vikkes/hansetag/backend/user-admin/src/common/logger', target file type 'TypeScript'.
File '/Users/vikkes/hansetag/backend/user-admin/src/common/logger.ts' exist - use it as a name resolution result.
======== Module name '@/common/logger' was successfully resolved to '/Users/vikkes/hansetag/backend/user-admin/src/common/logger.ts'. ========