-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Error setting up Local Environment following Contribution Guide: "Module not found: Can't resolve 'react'" #472
Comments
Hi there! I think it last came up in #181 I don't have React installed in next-auth locally when working on it, so I think it works already, but it is really fiddly. IME doing this causes problems when using the useSession Hook, which is why React is not a Annoyingly, any time you run I can only suggest trying the steps again really pedantically and seeing if that helps. I think they got improved the last time this came up. We do need to find a better solution to improve the DX as it's a PITA right now. Including an example project in |
Sorry, this is a long response, I got nerdsniped. Feel free to skip to the tl;dr 😁 I definitely agree, the I did see that other issue, and spent about an hour and a half trying (what I thought was) every permutation of installation & linking I could think of with both the Some more troubleshooting led me to a couple realizations, the first being that (perhaps obviously, but importantly) my project was looking in the So how to get my project to use the I don't understand tl;dr"My project" (whichever project) needs to How about this for a proposed update to the documentation? It would change the "option 1" as currently written to the "option 2" (basically swapping steps 3 & 4 as written):
option 1 - doesn't work:
option 2 - works:
Reference: These are the links I followed that got me to this solution: npm/npm#5875 > npm/npm#5875 (comment) > https://stackoverflow.com/a/38818358/1763258 This is a diagram I made to help my brain: |
Please fee free to submit a change to the steps in the CONTRIBUTING.md 👍 |
Resolved in v3 with update from @BenjaminWFox! |
Describe the bug
Setting up
next-auth
local environment following the steps in the contribution guide fails without explicitly installingreact
innext-auth
To Reproduce
git clone https://github.com/BenjaminWFox/next-auth.git
git clone https://github.com/iaincollins/next-auth-example.git
cd next-auth-example
npm install
cd ../next-auth
npm i
npm run build
npm link ../next-auth-example/node_modules/react
cd ../next-auth-example
npm link ../next-auth
npm run dev
To Fix
cd ../next-auth
npm i -D react
npm link ../next-auth-example/node_modules/react
cd ../next-auth-example
npm run dev
Additional context
The peer dependencies are called out at the various
npm
stages. I'm unsure, and didn't find via google, whether there is some other, better, way to solve this issue.If there is not a better way to resolve this issue (and/or if I'm not missing something obvious) and installing react (
npm i -D react
) is, in fact, the best way to resolve this situation I can submit a PR for the documentation in the Contributing Guide.I would change step 2 "Install packages and run the build command:" to:
Documentation feedback
Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.
The text was updated successfully, but these errors were encountered: