Next.js: Error: Cannot find module '/path/.next/build-manifest.json'

Created on 26 Mar 2020  路  10Comments  路  Source: vercel/next.js

Bug report

Describe the bug

When a SASS error happens, the Next CLI properly tells me about the SASS error, but then it prints this error to the console every few seconds until I fix the SASS error:

{ Error: Cannot find module '/Users/zach/dev/test/next-module-not-found-bug/.next/build-manifest.json'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.loadComponents (/Users/zach/dev/test/next-module-not-found-bug/node_modules/next/dist/next-server/server/load-components.js:29:9)
    at DevServer.findPageComponents (/Users/zach/dev/test/next-module-not-found-bug/node_modules/next/dist/next-server/server/next-server.js:529:60)
    at DevServer.renderErrorToHTML (/Users/zach/dev/test/next-module-not-found-bug/node_modules/next/dist/next-server/server/next-server.js:829:33)
    at DevServer.renderErrorToHTML (/Users/zach/dev/test/next-module-not-found-bug/node_modules/next/dist/server/next-dev-server.js:15:811)
    at process._tickCallback (internal/process/next_tick.js:68:7) code: 'MODULE_NOT_FOUND' }

To Reproduce

I've created a reproduction repository here.

Note: The SASS error in this repository is intentional to demonstrate this Next.js issue

  1. Run the following in a terminal:
git clone https://github.com/zposten/next-module-not-found-bug.git
cd next-module-not-found-bug
yarn
yarn start
  1. See error

Expected behavior

The SASS error should be printed a single time. This other error should not be printed to the terminal continuously.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: macOS 10.15.3
  • Version of Next.js: 9.3.2

Additional Context

Both of the apps that I've seen this issue in have

I have not exhaustively tested various configurations to figure out the precise cause of this issue.

This issue seems similar to:

  • #7839
  • #4660
  • #6287

...but all these issues are closed

story needs investigation

All 10 comments

This is a weird bug. I'm on an older version of Next (6.1.1, I should try updating!) but the error is weird. As mentioned in #4660, creating a blank build-manifest.json with the content {} fixes the issue (at least temporarily) and causes other more sensible errors to appear.

Had the same issue. Got it fixed by upgrading yarn
yarn upgrade

As soon as that was done, the build-manifest.json appeared.

Cheers!

Same issue here, i'm using NPM.

Just encountered this bug as well. Tried solutions from the other thread, to no success.

run into same bug

i also faced the same error whene I add new component to the pages!
what is your approach ?

i have this issue, when installing new project with typescript and adding aliases to folders in .babelrc and tsconfig

I tried install sass on my own with yarn add -D sass, the issue is resolved.

I tried install sass on my own with yarn add -D sass, the issue is resolved.

Not working for me (using npm).

I tried install sass on my own with yarn add -D sass, the issue is resolved.

I have tried it and it doesn't work

Was this page helpful?
0 / 5 - 0 ratings