0

I cannot import module from root path, example:

import { encryptPassword, generateLoginToken } from "src/helpers/crypto";

here is my tsconfig:

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es6",
    "outDir": "build",
    "rootDir": "src",
    "baseUrl": ".",
    "strict": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "strictPropertyInitialization": false,
  }
}

I am using VS Code. It is fine, the VS Code does not complain about the path, but after I run:

nodemon ./src/app.ts

There is error saying the module is not found:

Error: Cannot find module 'src/entity/owner'

If I use relative path:

import { encryptPassword, generateLoginToken } from "../helpers/crypto";

Then it works. I do not want to use relative path. How can I fix this?

Alvin Stefanus
  • 1,873
  • 2
  • 22
  • 60

0 Answers0