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

Missing module on Monorepo example #57

Closed
sergioutama opened this issue Aug 28, 2020 · 3 comments
Closed

Missing module on Monorepo example #57

sergioutama opened this issue Aug 28, 2020 · 3 comments
Labels
good first issue Good for newcomers monorepo Related to monorepo example

Comments

@sergioutama
Copy link
Contributor

sergioutama commented Aug 28, 2020

Describe the bug
Navigating to the route where next being served on monorepo example (eg: localhost:3000/about) will produce following error

Error: Cannot find module '../../ui/node_modules/next/dist/next-server/lib/constants.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:613:15)
    at Function.Module._load (internal/modules/cjs/loader.js:539:25)
    at Module.require (internal/modules/cjs/loader.js:667:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at eval (webpack-internal:///../next-server/lib/constants:1:18)
     at Object.../next-server/lib/constants (/Users/xxxx/nest-next/examples/monorepo/ui/.next/server/pages/_document.js:103:1)
    at __webpack_require__ (/Users/xxxx/nest-next/examples/monorepo/ui/.next/server/pages/_document.js:23:31)
    at eval (webpack-internal:///./node_modules/next/dist/pages/_document.js:20:18)
    at Object../node_modules/next/dist/pages/_document.js (/Users/xxxx/nest-next/examples/monorepo/ui/.next/server/pages/_document.js:148:1)
    at __webpack_require__ (/Users/xxxx/nest-next/examples/monorepo/ui/.next/server/pages/_document.js:23:31) code: 'MODULE_NOT_FOUND' }

Expected behavior
No error produced and the route serve the right component from nextjs

To Reproduce

  1. Clone this repo and run the example
  2. Build ui dto and server first (there is missing @types/webpack dependency, so i install it to ensure successful build)
  3. run npm run dev on server
  4. enter localhost:3000 or localhost:3000/about
  5. the page failed to load and following error is displayed in the server output
Error: Cannot find module '../../ui/node_modules/next/dist/next-server/lib/constants.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:613:15)
    at Function.Module._load (internal/modules/cjs/loader.js:539:25)
    at Module.require (internal/modules/cjs/loader.js:667:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at eval (webpack-internal:///../next-server/lib/constants:1:18)
     at Object.../next-server/lib/constants (/Users/xxxx/nest-next/examples/monorepo/ui/.next/server/pages/_document.js:103:1)
    at __webpack_require__ (/Users/xxxx/nest-next/examples/monorepo/ui/.next/server/pages/_document.js:23:31)
    at eval (webpack-internal:///./node_modules/next/dist/pages/_document.js:20:18)
    at Object../node_modules/next/dist/pages/_document.js (/Users/xxxx/nest-next/examples/monorepo/ui/.next/server/pages/_document.js:148:1)
    at __webpack_require__ (/Users/xxxx/nest-next/examples/monorepo/ui/.next/server/pages/_document.js:23:31) code: 'MODULE_NOT_FOUND' }

Version

  • next.js: 9.1.6
  • nest: 6.10.12
  • nest-next: 9.1.0
@NOtherDev
Copy link
Contributor

Also had this, was gone when I upgraded the dependencies, in particular next to 9.4.4 (but not the newest as it was failing with yet another esoteric error).

@sergioutama
Copy link
Contributor Author

@NOtherDev thanks for the tips, it help me solve the problem.
It seems the issue is in next repo itself

@kyle-mccarthy kyle-mccarthy added the monorepo Related to monorepo example label Sep 3, 2020
@kyle-mccarthy kyle-mccarthy added the good first issue Good for newcomers label Oct 1, 2020
@sergioutama
Copy link
Contributor Author

@kyle-mccarthy
I think we can close this issue. After further investigation, following @NOtherDev tips works and it's indeed NextJS issue.
Thanks for taking your time to look at this issue 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers monorepo Related to monorepo example
Projects
None yet
Development

No branches or pull requests

3 participants