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

Module not found: Can't resolve 'v8' #6558

Closed
socketopp opened this issue Jan 29, 2023 · 10 comments
Closed

Module not found: Can't resolve 'v8' #6558

socketopp opened this issue Jan 29, 2023 · 10 comments
Labels
incomplete Insufficient reproduction. Without more info, we won't take further actions/provide help. question Ask how to do something or how something works

Comments

@socketopp
Copy link

socketopp commented Jan 29, 2023

Question 💬

Environment

  System:
    OS: Windows 10 10.0.19045
    CPU: (6) x64 Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz
    Memory: 5.93 GB / 15.95 GB
  Binaries:
    Node: 18.12.1 - C:\node\node.EXE
    npm: 9.2.0 - C:\node\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (109.0.1518.70)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    next: ^13.1.2 => 13.1.2
    next-auth: ^4.19.0 => 4.19.0
    react: ^18.2.0 => 18.2.0

When importing the authOptions needed to call getServerSession I get the following issue.
Not sure why. Can't exactly pinpoint what in my config that causes the issue. Only using Google as a provider.

**Do I need to install v8 for this to work? **

I also get this error when I install v8 and ty to call getServerSession

TypeError: (0 , next_auth_react__WEBPACK_IMPORTED_MODULE_4__.getServerSession) is not a function

https://nextjs.org/docs/messages/module-not-found
wait  - compiling...
error - ./node_modules/openid-client/lib/helpers/deep_clone.js:1:33
Module not found: Can't resolve 'v8'

Import trace for requested module:
./node_modules/openid-client/lib/issuer.js
./node_modules/openid-client/lib/index.js
./node_modules/next-auth/core/lib/oauth/callback.js
./node_modules/next-auth/core/routes/callback.js
./node_modules/next-auth/core/routes/index.js
./node_modules/next-auth/core/index.js
./node_modules/next-auth/next/index.js
./node_modules/next-auth/index.js
./pages/api/auth/[...nextauth].js

How to reproduce ☕️

Just import authOptions and on that page it will require v8.

import { authOptions } from '../../pages/api/auth/[...nextauth]';

Contributing 🙌🏽

Yes, I am willing to help answer this question in a PR

@socketopp socketopp added the question Ask how to do something or how something works label Jan 29, 2023
@balazsorban44 balazsorban44 added the incomplete Insufficient reproduction. Without more info, we won't take further actions/provide help. label Jan 29, 2023
@github-actions
Copy link

We cannot recreate the issue with the provided information. Please add a reproduction in order for us to be able to investigate.

Why was this issue marked with the incomplete label?

To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository (template), but you can also use a tool like CodeSandbox or StackBlitz.

To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue.

Please test your reproduction against the latest version of NextAuth.js (next-auth@latest) to make sure your issue has not already been fixed.

I added a link, why was it still marked?

Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.

What happens if I don't provide a sufficient minimal reproduction?

Issues with the incomplete label that receives no meaningful activity (e.g. new comments with a reproduction link) are automatically closed and locked after 30 days.

If your issue has not been resolved in that time and it has been closed/locked, please open a new issue with the required reproduction.

I did not open this issue, but it is relevant to me, what can I do to help?

Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps. Furthermore, you can upvote the issue using the 👍 reaction on the topmost comment (please do not comment "I have the same issue" without repro steps). Then, we can sort issues by votes to prioritize.

I think my reproduction is good enough, why aren't you looking into it quicker?

We look into every NextAuth.js issue and constantly monitor open issues for new comments.

However, sometimes we might miss one or two. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.

Upvoting issues to show your interest will help us prioritize and address them as quickly as possible. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.

Useful Resources

@acc-nicholas

This comment was marked as spam.

@balazsorban44
Copy link
Member

balazsorban44 commented Jan 30, 2023

@acc-nicholas

This comment was marked as off-topic.

@balazsorban44
Copy link
Member

balazsorban44 commented Jan 31, 2023

getInitialProps is called both on the server and in the browser, so it won't have the Node.js-only v8 module, hence the error. Please refer to the Next.js docs. We also don't document using getServerSession with getInitialProps, if you have seen this recommended somewhere, could you point me to it? So this is unfortunately not a valid reproduction.

trying to follow the docs to get started on a new app

Could you point me to where getInitialProps+getServerSideProps was documented? It's likely a bad recommendation and I would like to review it.

@erbaafidotama

This comment was marked as off-topic.

@balazsorban44
Copy link
Member

#6558 (comment)

@balazsorban44
Copy link
Member

Closing, as I am fairly confident in my comment here: #6558 (comment)

Feel free to open a new issue with a reproduction.

@RomainMorlevat
Copy link

@balazsorban44 I have the same problem and found this issue.

Could you point me to where getInitialProps+getServerSideProps was documented? It's likely a bad recommendation and I would like to review it.

Here: https://next-auth.js.org/getting-started/client#sessionprovider

If every one of your pages needs to be protected, you can do this in getInitialProps in _app, otherwise you can do it on a page-by-page basis

@jokester
Copy link

jokester commented Feb 18, 2023

The SessionProvider example used pageProps.session in _app.tsx, but not pointing out how the initial session could be provided. The only solution I found is to getServerSideProps in (every) Page Component.

The document follows:

If every one of your pages needs to be protected, you can do this in getInitialProps in _app, otherwise you can do it on a page-by-page basis

If this can really be done in a App.getInitialProps(), maybe we should document it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incomplete Insufficient reproduction. Without more info, we won't take further actions/provide help. question Ask how to do something or how something works
Projects
None yet
Development

No branches or pull requests

6 participants