Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

362
Views
Error: Cannot find module 'src/entities/Post'

so i am creating a graphQL server using type-graph and mikro-orm everything was fine till i got this error that says => Error: Cannot find module 'src/entities/Post' and that module exists as you can see in this picture: folder structure

and this is what the error looks like int the terminal: error in the terminal

by the way i am using script called watch: "tsc -w" to convert typescript into javascript.

this is a code example of my postResolver:

import { Post } from './src/entities/Post';
import { MyContext } from 'src/types';
import {Ctx, Query, Resolver} from 'type-graphql';

@Resolver()
export class postResolver {
    @Query(()=> [Post])
    posts(@Ctx() {em}: MyContext) : Promise<Post[]>{
        return em.find(Post, {})
    }
}
it says that the module ./src/entities/Post does not exist while it exists and i really don't know why

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Fastest way to solve it would be using relative imports (import { Post } from '../entities/Post') instead of absolute like you did.

Another way to satisfy node to keep using absolute paths, is adding the following to your tsconfig file. Note that you will need to add a path for every directory at 'src' level, you want to import.

"compilerOptions": {
  "baseUrl": "src",
  "paths": {
     "src/*": ["src/*"],
     "entities/*": ["src/entities/*"],
     "resolvers/*": ["src/resolvers/*"]
     ...
  },
  ...
}

Or you could use a package like this one installed to your devDependecies

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!