next.js: AMP First Pages: Could not find files for /xxx in .next/build-manifest.json

Bug report

Describe the bug

When AMP first pages are accessed, the following error statement outputs. Could not find files for /xxx in .next/build-manifest.json.

These AMP pages can be viewed.

To Reproduce

  1. cd /zeit/next.js/examples/amp-first
  2. npm i
  3. npm run build
  4. npm run start
  5. Go to ‘localhost:3000’
  6. See following error in your console
> next start

ready - started server on http://localhost:3000
Could not find files for / in .next/build-manifest.json

Expected behavior

No error outputs.

Screenshots

None.

System information

  • OS: macOS
  • Browser (if applies) Chrome
  • Version of Next.js: v9.5.3
  • Version of Node.js: v13.14.0

Additional context

This error will be called in getPageFiles here. getPageFiles will be called in getDocumentFiles here. getDocumentFiles is called when rendering all pages that use _document. So all pages might pass this function.

But I found that AMP First Pages was not included in build-manifest.json’s pages (PR). And, when AMPState ampFirst is true, the amp page files were excluded by render.tsx. However, This PR seems to be removed that feature and caused the error.

It may be roughly solved the following way in _document.tsx.

before:

    const files: DocumentFiles = getDocumentFiles(
      this.context.buildManifest,
      this.context.__NEXT_DATA__.page
    )

after:

    const files: DocumentFiles = inAmpMode ? {
      sharedFiles: [],
      pageFiles: [],
      allFiles: [],
    } : getDocumentFiles(
      this.context.buildManifest,
      this.context.__NEXT_DATA__.page
    )

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 7
  • Comments: 25 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I’m having this issue with next v11.0.1

Does anyone review it?

+1 with Next v11.0.1 and not only with AMP pages, but occasionally with any page in dev mode which is accessed for the first time.

Heads up - I’ve managed to fix this by updating webpack via

yarn add webpack --dev

Same here Could not find files for /xxx in .next/build-manifest.json

Try , delete .next folder, again run server and Ctrl+Shift+R in Browser

+1 same here

Me too, and not only on AMP pages.

even now i am getting this for / wth is happening. did anyone found something.

Error:

Could not find files for / in .next/build-manifest.json

+1 with Next v11.0.1 (…) occasionally with any page in dev mode which is accessed for the first time.

Same here.

Thank you! I did upgrade to next 10.1.3 remode node modules and yanr.lock. After that I did yarn install again and everything went well 😃

Hi! I am having a similar bug setting up AMP first pages. Is there any resolve for this?

Error message: /xxx in .next/build-manifest.json Here is what my build-manifest.json file looks like. It seems that the AmpFirstPages isn’t being populated properly…or at all I would really love some help figuring this out please! Thank you!

amp2 amp