vtdiep / pk-ordering

0 stars 0 forks source link

Can't Find Absolute Path When Testing #1

Closed vtdiep closed 3 years ago

vtdiep commented 3 years ago

npm test is unable to find modules/files/etc that have an absolute path such as import { PrismaService } from 'src/common/database/prisma/prisma.service';

Changing this to relative path will work: import { PrismaService } from '../../src/common/database/prisma/prisma.service';

vtdiep commented 3 years ago

https://github.com/nestjs/nest/issues/4953 seems to solve this issue, but its unknown if this fix would still work in production. The PR was not merged, with "Using absolute imports with src included is not recommended and is considered a bad practice." as the reason given by the creator of nestjs.

For reference, some discussion of the reason behind this can be found here: https://github.com/nestjs/typescript-starter/issues/74#issuecomment-464698726. Also in this thread is a solution to enable use of absolute paths in production.