vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.28k stars 26.77k forks source link

Error: Cannot find module './runtime' #5868

Closed Enalmada closed 5 years ago

Enalmada commented 5 years ago

When trying to upgrade from 7.0.2 to v7.0.2-canary.42 I can build ok but get the following error when hitting the first page:

{ Error: Cannot find module './runtime'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.uqG8 (C:\Users\Adam\code\public\next-reason-boilerplate\.next\server\static\pG0J7KxMZx_VHzleY1EvL\pages\_app.js:1136:18)
    at __webpack_require__ (C:\Users\Adam\code\public\next-reason-boilerplate\.next\server\static\pG0J7KxMZx_VHzleY1EvL\pages\_app.js:23:31)
    at Object.QcLC (C:\Users\Adam\code\public\next-reason-boilerplate\.next\server\static\pG0J7KxMZx_VHzleY1EvL\pages\_app.js:569:18)
    at __webpack_require__ (C:\Users\Adam\code\public\next-reason-boilerplate\.next\server\static\pG0J7KxMZx_VHzleY1EvL\pages\_app.js:23:31)
    at Object.ln6h (C:\Users\Adam\code\public\next-reason-boilerplate\.next\server\static\pG0J7KxMZx_VHzleY1EvL\pages\_app.js:790:18)
    at __webpack_require__ (C:\Users\Adam\code\public\next-reason-boilerplate\.next\server\static\pG0J7KxMZx_VHzleY1EvL\pages\_app.js:23:31)
    at Module.B5Ud (C:\Users\Adam\code\public\next-reason-boilerplate\.next\server\static\pG0J7KxMZx_VHzleY1EvL\pages\_app.js:139:19)
    at __webpack_require__ (C:\Users\Adam\code\public\next-reason-boilerplate\.next\server\static\pG0J7KxMZx_VHzleY1EvL\pages\_app.js:23:31)
    at Object.0 (C:\Users\Adam\code\public\next-reason-boilerplate\.next\server\static\pG0J7KxMZx_VHzleY1EvL\pages\_app.js:106:18)
    at __webpack_require__ (C:\Users\Adam\code\public\next-reason-boilerplate\.next\server\static\pG0J7KxMZx_VHzleY1EvL\pages\_app.js:23:31)
    at C:\Users\Adam\code\public\next-reason-boilerplate\.next\server\static\pG0J7KxMZx_VHzleY1EvL\pages\_app.js:91:18
    at Object.<anonymous> (C:\Users\Adam\code\public\next-reason-boilerplate\.next\server\static\pG0J7KxMZx_VHzleY1EvL\pages\_app.js:94:10) code: 'MODULE_NOT_FOUND' }

Error happens in dev and production setting. Is this a known issue in canary.42 or is there something my codebase might be doing to cause it?

System information

UPDATE: I believe I have traced the problem to module babel-plugin-react-intl. Problem seem to go away when I remove that module and these lines: https://github.com/zeit/next.js/blob/master/examples/with-react-intl/.babelrc#L5-L18

timneutkens commented 5 years ago

Most likely not related to Next.js, we didn't even upgrade Babel in the canary releases as far as I can remember. The integration tests on Next.js are passing between stable and canary (canary has even more tests). It seems like you're importing a runtime module that does not exist in your app or something. Maybe it's related to babel caching? Try rm -rf node_modules/.cache.

Enalmada commented 5 years ago

@timneutkens Thanks for your feedback. The with-react-intl example works in canary so there indeed must be something more going on. Removing node_modules directory also seems to be required. Will close ticket since I can live without the babel-plugin-react-intl functionality and I don't get the error in canary when I remove it. I will reopen if anyone else hits this issue as they upgrade.

willross commented 5 years ago

Experiencing the same issue, however even deleting .babelrc and babel-plugin-react-intl didn't help in my case (8.0.0-canary.2)

EDIT: running npm cache clean --force and deleting package-lock.json before reinstalling node-modules have helped.

balupton commented 5 years ago

Just ran into this.

 DONE  Compiled successfully in 1797ms                                                                                                                                9:16:28 am

{ Error: Cannot find module './runtime'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object../runtime (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:1136:18)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at Object../node_modules/next/node_modules/regenerator-runtime/runtime-module.js (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:1100:18)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at Object../node_modules/@babel/runtime-corejs2/regenerator/index.js (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:513:18)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at Module../node_modules/next/dist/pages/_app.js (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:759:92)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at Object.0 (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:1147:18)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at /Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:91:18
    at Object.<anonymous> (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:94:10) code: 'MODULE_NOT_FOUND' }
{ Error: Cannot find module './runtime'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object../runtime (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:1136:18)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at Object../node_modules/next/node_modules/regenerator-runtime/runtime-module.js (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:1100:18)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at Object../node_modules/@babel/runtime-corejs2/regenerator/index.js (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:513:18)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at Module../node_modules/next/dist/pages/_app.js (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:759:92)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at Object.0 (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:1147:18)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at /Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:91:18
    at Object.<anonymous> (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:94:10) code: 'MODULE_NOT_FOUND' }
{ Error: Cannot find module './runtime'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object../runtime (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:1136:18)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at Object../node_modules/next/node_modules/regenerator-runtime/runtime-module.js (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:1100:18)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at Object../node_modules/@babel/runtime-corejs2/regenerator/index.js (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:513:18)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at Module../node_modules/next/dist/pages/_app.js (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:759:92)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at Object.0 (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:1147:18)
    at __webpack_require__ (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:23:31)
    at /Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:91:18
    at Object.<anonymous> (/Users/balupton/Projects/websites/jordanbpeterson.community/.next/server/static/development/pages/_app.js:94:10) code: 'MODULE_NOT_FOUND' }
^Cgot signal SIGINT, exiting

Doing:

rm -Rf node_modules package-lock.json

Then using yarn instead of npm resolved it for me.

Cache cleaning npm did not resolve it for me.

Yarn did report:

> yarn
yarn install v1.12.3
info No lockfile found.
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
warning eslint > file-entry-cache > flat-cache > circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
warning projectz > spdx@0.5.2: see spdx-expression-parse, spdx-satisfies, &c.
warning projectz > season > cson-parser > coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
[3/5] 🚚  Fetching packages...
[4/5] 🔗  Linking dependencies...
warning "@zeit/next-typescript > @babel/preset-typescript@7.1.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "@zeit/next-typescript > @babel/preset-typescript > @babel/plugin-transform-typescript@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "@zeit/next-typescript > @babel/preset-typescript > @babel/plugin-transform-typescript > @babel/plugin-syntax-typescript@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
[5/5] 📃  Building fresh packages...
success Saved lockfile.
✨  Done in 48.41s.

So perhaps the peer deps there are the issue.

seawatts commented 5 years ago

I'm still running into this issue. Cleaning cache and node_modules didn't help

balupton commented 5 years ago

@seawatts are you using yarn or npm? I had to switch to yarn for it to work. Also if you are using yarn, try switch to the canary tag for all zeit packages.

seawatts commented 5 years ago

Using npm. I haven't tried to upgrade other next dependencies. I just reverted back to 7 for now

On Wed, Jan 16, 2019, 23:16 Benjamin Lupton notifications@github.com wrote:

@seawatts https://github.com/seawatts are you using yarn or npm? I had to switch to yarn for it to work. Also if you are using yarn, try switch to the canary tag for all zeit packages.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zeit/next.js/issues/5868#issuecomment-455066944, or mute the thread https://github.com/notifications/unsubscribe-auth/ACDIwoweljHWGVoH1A4te3IqZhrcaSrNks5vECNngaJpZM4ZOwCb .

NathanielHill commented 5 years ago

FWIW I've also run into this in an unrelated project. I believe it's due to @babel/plugin-tranform-runtime injecting that require statement, but then @babel/runtime is not handling it. It for sure has something to do with both those modules.

I was trying to transpile some React components using async/await with Babel 7. I ended up removing those two packages completely and requiring regenerator-runtime/runtime.js in the main entry point.