Skip to content

next build fails with any manifest.json file in root of app directory #59923

@joshunger

Description

@joshunger

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/suspicious-lalande-2q96d2

To Reproduce

Follow these steps https://nextjs.org/docs/app/api-reference/file-conventions/metadata/manifest to add a manifest.json or run yarn build from the codesandbox.

Current vs. Expected behavior

Build fails

yarn run v1.22.19
$ next build
   ▲ Next.js 14.0.5-canary.26

   Creating an optimized production build  ..Failed to compile.

./node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js?page=%2Fmanifest.json%2Froute&isDynamic=0!./app/manifest.json?__next_metadata_route__
Module parse failed: Cannot parse JSON: Unexpected token 'i', "import { N"... is not valid JSON while parsing 'import { NextResponse } from 'next/serve'
File was processed with these loaders:
 * ./node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js
You may need an additional loader to handle the result of these loaders.
Error: Cannot parse JSON: Unexpected token 'i', "import { N"... is not valid JSON while parsing 'import { NextResponse } from 'next/serve'
    at JsonParser.parse (/workspace/node_modules/next/dist/compiled/webpack/bundle5.js:28:997642)
    at /workspace/node_modules/next/dist/compiled/webpack/bundle5.js:28:403525
    at processResult (/workspace/node_modules/next/dist/compiled/webpack/bundle5.js:28:399309)
    at /workspace/node_modules/next/dist/compiled/webpack/bundle5.js:28:400370
    at /workspace/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8727
    at iterateNormalLoaders (/workspace/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5565)
    at iterateNormalLoaders (/workspace/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5650)
    at /workspace/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5879
    at /workspace/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4271

Import trace for requested module:
./node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js?page=%2Fmanifest.json%2Froute&isDynamic=0!./app/manifest.json?__next_metadata_route__


> Build failed because of webpack errors
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 14.0.5-canary.26
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure, App Router, Metadata (metadata, generateMetadata, next/head)

Additional context

NEXT-2439

Metadata

Metadata

Assignees

No one assigned

    Labels

    MetadataRelated to Next.js' Metadata API.linear: nextConfirmed issue that is tracked by the Next.js team.locked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions