# Error when migrate to nextjs-auth0 v4.1 Cannot find module '@/lib/auth0'

**URL:** <https://community.auth0.com/t/error-when-migrate-to-nextjs-auth0-v4-1-cannot-find-module-lib-auth0/183972>\
**Category:** Get Help\
**Tags:** rules-configs, management-api\
**Created:** [March 17, 2025, 10:19am UTC](https://community.auth0.com/t/error-when-migrate-to-nextjs-auth0-v4-1-cannot-find-module-lib-auth0/183972 "2025-03-17T10:19:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nguyen.cao](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nguyen.cao/32/73686_2.png) [@nguyen.cao](https://community.auth0.com/u/nguyen.cao)\
**Post date:** [March 17, 2025, 10:19am UTC](https://community.auth0.com/t/error-when-migrate-to-nextjs-auth0-v4-1-cannot-find-module-lib-auth0/183972/1 "2025-03-17T10:19:18Z")

</div>

Ready to post? 🔍 First, try searching for your answer.  
Hi,

I try t migrate from V2.7 to V4.1  
My source using folder src.  
I create file src/lib/auth0.ts

```auto
import { Auth0Client } from '@auth0/nextjs-auth0/server'

export const auth0 = new Auth0Client({
  authorizationParameters: {
    audience: process.env.AUTH0_AUDIENCE,
    scope: process.env.AUTH0_SCOPE
  }
})

```

I put path in tsconfig.server.json

```auto
    "baseUrl": ".",
    "paths": {
      "@/lib/*": ["src/lib/*"]
    }

```

I imported into server/services/auth.ts

```auto
import { auth0 } from '@/lib/auth0'

```

And get the error when run ‘yarn dev’

```auto
[nodemon] starting `ts-node --project tsconfig.server.json server/index.ts`
Error: Cannot find module '@/lib/auth0'

```

try to add path to tsconfig.json and still get the same error.  
Please help me.

---

<div class="post-metadata">

**Author:** ![nguyen.cao](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nguyen.cao/32/73686_2.png) [@nguyen.cao](https://community.auth0.com/u/nguyen.cao)\
**Post date:** [March 17, 2025, 10:22am UTC](https://community.auth0.com/t/error-when-migrate-to-nextjs-auth0-v4-1-cannot-find-module-lib-auth0/183972/2 "2025-03-17T10:22:56Z")

</div>

Ready to post? 🔍 First, try searching for your answer.  
Hi,  
I get this error when using node version 22 and try to run ‘yarn dev’ for nextjs-auth0 version 4.1  
Please help me.

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [March 17, 2025, 12:14pm UTC](https://community.auth0.com/t/error-when-migrate-to-nextjs-auth0-v4-1-cannot-find-module-lib-auth0/183972/3 "2025-03-17T12:14:00Z")

</div>

Hi @nguyen.cao

Welcome to the Auth0 Community!

Thank you for posting your question!

Can you open up a new issue in the Next.js Auth0 repository → [GitHub · Where software is built](https://github.com/auth0/nextjs-auth0/issues) and link it here. After that I will ping the repo owners to check your issue and address it!

Thanks  
Dawid

---

<div class="post-metadata">

**Author:** ![nguyen.cao](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nguyen.cao/32/73686_2.png) [@nguyen.cao](https://community.auth0.com/u/nguyen.cao)\
**Post date:** [March 18, 2025, 8:05am UTC](https://community.auth0.com/t/error-when-migrate-to-nextjs-auth0-v4-1-cannot-find-module-lib-auth0/183972/4 "2025-03-18T08:05:32Z")

</div>

Hi @dawid.matuszczyk  
I created issued in github.  
How can I link it?

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [March 18, 2025, 11:08am UTC](https://community.auth0.com/t/error-when-migrate-to-nextjs-auth0-v4-1-cannot-find-module-lib-auth0/183972/5 "2025-03-18T11:08:06Z")

</div>

I got it for you!

> <https://github.com/auth0/nextjs-auth0/issues/1972>
>
> \### Checklist
> 
> \- \[x\] The issue can be reproduced in the \[nextjs-auth0 sample app…\](https://github.com/auth0-samples/auth0-nextjs-samples/tree/main/Sample-01) (or N/A).
> \- \[x\] I have looked into the \[Readme\](https://github.com/auth0/nextjs-auth0#readme), \[Examples\](https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md), and \[FAQ\](https://github.com/auth0/nextjs-auth0/blob/main/FAQ.md) and have not found a suitable solution or answer.
> \- \[x\] I have looked into the \[API documentation\](https://auth0.github.io/nextjs-auth0/) and have not found a suitable solution or answer.
> \- \[x\] I have searched the \[issues\](https://github.com/auth0/nextjs-auth0/issues) and have not found a suitable solution or answer.
> \- \[x\] I have searched the \[Auth0 Community\](https://community.auth0.com) forums and have not found a suitable solution or answer.
> \- \[x\] I agree to the terms within the \[Auth0 Code of Conduct\](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md).
> 
> \### Description
> 
> I try to use in server with express and ts-node.
> When I use \`import { auth0 } from "@/lib/auth0"\`, will get error \`MODULE\_NOT\_FOUND\`.
> If I use \`import { auth0 } from "../../src/lib/auth0"\` will get error \`ERR\_PACKAGE\_PATH\_NOT\_EXPORTED\`
> 
> Link to Auth0 community
> https://community.auth0.com/t/error-when-migrate-to-nextjs-auth0-v4-1-cannot-find-module-lib-auth0/183972
> 
> \### Reproduction
> 
> \[my-next-express-app.zip\](https://github.com/user-attachments/files/19311585/my-next-express-app.zip)
> In the folder run \`yarn\` then \`yarn dev\` will get the error
> 
> \### Additional context
> 
> \_No response\_
> 
> \### nextjs-auth0 version
> 
> 4.1
> 
> \### Next.js version
> 
> 15.1.7
> 
> \### Node.js version
> 
> 22.14.0

---

<div class="post-metadata">

**Author:** ![nguyen.cao](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nguyen.cao/32/73686_2.png) [@nguyen.cao](https://community.auth0.com/u/nguyen.cao)\
**Post date:** [March 19, 2025, 1:50am UTC](https://community.auth0.com/t/error-when-migrate-to-nextjs-auth0-v4-1-cannot-find-module-lib-auth0/183972/6 "2025-03-19T01:50:07Z")

</div>

Thank you @dawid.matuszczyk .  
Looking forward to get feedback soon.

---

<div class="post-metadata">

**Author:** ![nguyen.cao](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nguyen.cao/32/73686_2.png) [@nguyen.cao](https://community.auth0.com/u/nguyen.cao)\
**Post date:** [March 24, 2025, 2:10am UTC](https://community.auth0.com/t/error-when-migrate-to-nextjs-auth0-v4-1-cannot-find-module-lib-auth0/183972/7 "2025-03-24T02:10:49Z")

</div>

Hi,  
Do we have a feedback for this bug?
