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

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:

…but all these issues are closed

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 29
  • Comments: 33 (3 by maintainers)

Most upvoted comments

I resolved this error by removing the .next folder and node_modules and reinstalling with yarn.

rm -rf .next
rm -rf node_modules
yarn

I upgraded from 10.2.1 to 11.0.1 and went into this problem. Still found no fix 😦

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

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

Cheers!

delete .next folder fixed issue for me

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

I upgraded from 9 to 10 and went into this problem. image

Usin NPM

This issue is blocking me from upgrading from 12.0.7 to 12.0.9 (or 12.0.10). As long as I stay on 12.0.7 I’m fine, but if I try to upgrade to 12.0.9 (or 12.0.10), I hit this error. I have tried deleting .next.

I’m using Node 16.13.1 and pnpm 6.29.1.

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

I would also recommend making sure you are on an active node js version by running node --version on your terminal (for example, v14.15.4, at the time of this comment, or v12.20.1 if you are planning on using Vercel’s infrastructure).

Adding:

  "engines": {
    "node": ">=12.x"
  }

on your package.json file may also help, if you are using Vercel’s infrastructure. Currently they only seem to support node until v12: https://vercel.com/docs/runtimes#official-runtimes/node-js/node-js-version

I tried to upgrade yarn and no success.

I’m too facing the error on next:12.1.14 It is trying to require .next/build-manifest.json but there is no such manifest file inside .next. Any clue on the significance of the that file. It tries to require /.next/react-loadable-manifest.json /.next/server/middleware-flight-manifest.json

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