[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live)

[Help](/c/help/9)

# Vercel build cannot resolve src/* path aliases in NestJS project

312 views · 2 likes · 10 posts


Morezadev (@morezadev) · 2025-09-13 · ♥ 1

Hi Vercel team 

I’m deploying a NestJS project to Vercel and hitting an issue with module resolution.
On local development and other hosting providers, my imports like this work fine:

```typescript
import Roles from 'src/common/guards/verify-jwt.guard'

```

When deployed to Vercel, the build succeeds but runtime fails with:
![error|690x326](upload://cGjeMMPeigdoqpqSefSbkWOjBck.jpeg)

this is i define databaseModule : 
```
import { DatabaseModule } from 'src/modules/database/database.module';
```

i think the error because vercel cannot understand the "src" path, i founded the solution by remove the src/ and write actual manual path like "../../..." instead of "src/" but it have more than 50 constants and props imported automaticly, so what is your suggestion to fix that?


Herge (@fullyherge) · 2025-11-06

Seeing this same issue, with a slightly different error logged:

```
Cannot find module '@api/auth/auth.module'
Require stack:
- /var/task/apps/api/src/app.module.js
- /var/task/apps/api/src/main.js
Did you forget to add it to "dependencies" in `package.json`?
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.
```

Looks to me like it is finding the proper `.js` files but somewhere in the import chain it starts looking at the uncompiled aliased paths instead of the built relative ones.

I also don’t see it as a feasible solution to skip using import aliases in a large codebase, especially a monorepo.


Anshuman Bhardwaj (@anshumanb) · 2025-11-06

Hi @morezadev @fullyherge, I'm sorry you are facing this issue. Can you share a public repo or a [minimal reproducible example](https://vercel.com/guides/creating-a-minimal-reproducible-example). That will let us all work together from the same code to figure out what’s going wrong.

What does your tsconfig look like?


Herge (@fullyherge) · 2025-11-06 · ♥ 1

Absolutely, here’s an attempt at a minimal repro:

https://github.com/fullystudios/nestjs-monorepo-vercel-repro


Here’s the Vercel project, if you can check the logs:

https://vercel.com/fully-studios-team/nestjs-monorepo-vercel-repro-api/logs


Anshuman Bhardwaj (@anshumanb) · 2025-11-07

Hi @fullyherge, thanks. Let me try to recreate this.


Michael Rzero (@michael-rzero) · 2025-11-26

Also seeing this present in the same way


Anshuman Bhardwaj (@anshumanb) · 2025-11-27

Hi @morezadev, welcome to the Vercel Community!

I found the following solution from a [StackOverflow post](https://stackoverflow.com/a/77678651):

The solution (for now, at least) is to replace all your imports with relative paths, like so :

from -> `import { UsersService } from 'src/users/users.service';`

to ----> `import { UsersService } from '../users/users.service';`

Have you tried this?


Eugenio Berretta (@euberdeveloper) · 2026-01-22

Would you really expect someone to rewrite all the imports from the src alias (it is a standard in Nest.js) to infinite “../../../../”?


Anshuman Bhardwaj (@anshumanb) · 2026-01-23

Hi @morezadev, just checking in on your issue with the Vercel build and path aliases in your NestJS project. Did you manage to find a solution, or do you still need assistance? Happy to help.


Eugenio Berretta (@euberdeveloper) · 2026-01-25

Hello @anshumanb , I am not sure about the creator of this issue, but I’m having the same problem with NestJS and the src alias right not. I guess it’s a structural issue on the Vercel side, and not using the “src” aliases is not a good solution. Are there plans for a fix?

Thank you in advance