Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't Find Absolute Path When Testing #1

Closed
vtdiep opened this issue Jan 12, 2021 · 1 comment
Closed

Can't Find Absolute Path When Testing #1

vtdiep opened this issue Jan 12, 2021 · 1 comment
Labels
for reference Just for reference

Comments

@vtdiep
Copy link
Owner

vtdiep commented Jan 12, 2021

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 vtdiep added the for reference Just for reference label Jan 12, 2021
@vtdiep
Copy link
Owner Author

vtdiep commented Jan 12, 2021

nestjs/nest#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: nestjs/typescript-starter#74 (comment). Also in this thread is a solution to enable use of absolute paths in production.

@vtdiep vtdiep closed this as completed Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for reference Just for reference
Projects
None yet
Development

No branches or pull requests

1 participant