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

create-next-app (js): Cannot find module 'react' #204

Closed
bbigras opened this issue Jul 19, 2022 · 3 comments · Fixed by #208
Closed

create-next-app (js): Cannot find module 'react' #204

bbigras opened this issue Jul 19, 2022 · 3 comments · Fixed by #208
Labels
bug Something isn't working nodejs

Comments

@bbigras
Copy link

bbigras commented Jul 19, 2022

nix shell "nixpkgs#nodejs"

npx create-next-app@latest test-next-dream

cd test-next-dream

rm -rf node_modules

nix flake init -t github:nix-community/dream2nix#simple

nix eval --impure --raw --expr 'builtins.currentSystem' > ./nix_systems && git add ./nix_systems

nix flake show

nix develop

npm run dev

output of the last command

[bbigras@desktop:~/dev/test-next-dream]$ npm run dev

> [email protected] dev /home/bbigras/dev/test-next-dream
> next dev

internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module 'react'
Require stack:
- /nix/store/bpdi0095q7ww9fy886409cs8mxzjsw6m-next-12.2.2/lib/node_modules/next/dist/server/utils.js
- /nix/store/bpdi0095q7ww9fy886409cs8mxzjsw6m-next-12.2.2/lib/node_modules/next/dist/bin/next
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/nix/store/bpdi0095q7ww9fy886409cs8mxzjsw6m-next-12.2.2/lib/node_modules/next/dist/server/utils.js:11:37)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/nix/store/bpdi0095q7ww9fy886409cs8mxzjsw6m-next-12.2.2/lib/node_modules/next/dist/server/utils.js',
    '/nix/store/bpdi0095q7ww9fy886409cs8mxzjsw6m-next-12.2.2/lib/node_modules/next/dist/bin/next'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `next dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/bbigras/.npm/_logs/2022-07-19T19_30_09_416Z-debug.log
@DavHau DavHau added bug Something isn't working nodejs labels Jul 22, 2022
@DavHau
Copy link
Member

DavHau commented Jul 22, 2022

The reason seems to be a peerDependency issue.
next declares react as a peer dependency, but peer dependencies are not part of the v1part of the lock file.
At least we should raise a warning during build, that peerDependencies are missing, and show a hint on how to fix this with the inject API.

@bbigras
Copy link
Author

bbigras commented Jul 23, 2022

Could #195 help with this?

@DavHau
Copy link
Member

DavHau commented Jul 23, 2022

Probably, but it is a huge change which might take a while to stabilize.
For now I already have local changes that fix the devShell problem and improve general interoperability with the npm tool. I just need to make a PR with these changes and the current issue will be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working nodejs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants