next.js: 'Error: Cannot find module '/build-manifest.json'' masks an underlying issue

Bug report

Describe the bug

The error Cannot find module 'C:\Dropbox\NextRepro\next-error-reproduction\.next\build-manifest.json' is printed to console, and browser is not being served any useful errors when masking an underlying issue from Webpack. This only happens for me in dev mode.

The underlying issue in my specific case is that ts-loader does not exist, but I would expect the error from Webpack to be shown and not a not-so-useful error message about a build manifest not found 👍

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Go to https://github.com/eweilow/next-error-reproduction
  2. Clone the repo
  3. Install npm dependencies, run npm run dev
  4. Open http://localhost:3000
  5. View console and browser (which show different errors in this case, but not anything about ts-loader)

Running npm run build shows the real issue from Webpack, which is that ts-loader does not exist. I’m aware that the dependency is not in package.json, which is intentional to show the error.

Expected behavior

I would expect the correct error (Can't resolve 'ts-loader' in '<path>/next-error-reproduction') to be printed to both console and browser.

System information

  • OS: Windows
  • Browser (if applies): N/A
  • Version of Next.js: `6.0.2-canary.8

Additional context

Might be similar in nature to https://github.com/zeit/next.js/issues/4598

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 12
  • Comments: 18 (5 by maintainers)

Most upvoted comments

Please don’t bump issues.

Happened to me too!!! Just by importing a non existing module on _app.js or any other page.

NODE_ENV=production next build usually reveals the hidden error for me… 🤔

For now, if you’re getting this and want to know what the underlying cause is, try creating a fake build-manifest.json with {} in it. It revealed the actual error for me

Happened to me after i rename layout.js to Layout.js. The command below may help.

git config core.ignorecase false
git status

Might be similar in nature to #4598

Just to confirm, this is unrelated and not the same issue.

I guess if nothing breaks we can enable emit

I’m getting this too.

I see it happen after a restart my server and a package can’t be found from my _error.js page.

I can reliably reproduce by creating a syntax error in _error.js and then restarting the server.

webpack: wait until bundle finished:
 ERROR  Failed to compile with 1 errors                                                                                                                               20:02:18

This dependency was not found:

* @live/next-error in ./packages/xxx/apps/xxx/packages/app/pages/_error.js

To install it, you can run: npm install --save @live/next-error


...


# NOTE: I am hooking Module.resolveFilename for logging purposes.
{ Error: Cannot find module 'xxx/packages/xxx/apps/xxx/packages/app/build/local/dev/build-manifest.json'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._resolveFilename (xxx/packages/public/framework/server-init/index.js:270:41)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at _callee3$ (xxx/node_modules/.registry.npmjs.org/@vjpr/next/6.1.0-vjpr.1/node_modules/@vjpr/next/dist/server/render.js:203:29)
    at tryCatch (xxx/node_modules/.registry.npmjs.org/regenerator-runtime/0.11.1/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (xxx/node_modules/.registry.npmjs.org/regenerator-runtime/0.11.1/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (xxx/node_modules/.registry.npmjs.org/regenerator-runtime/0.11.1/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (xxx/node_modules/.registry.npmjs.org/@babel/runtime/7.0.0-beta.49/node_modules/@babel/runtime/helpers/asyncToGenerator.js:12:30)
    at _next (xxx/node_modules/.registry.npmjs.org/@babel/runtime/7.0.0-beta.49/node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:9)
    at <anonymous> code: 'MODULE_NOT_FOUND' }