Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APIPage Build fail - SyntaxError: Bad control character in string literal in JSON at position 1143 #893

Closed
devnjw opened this issue Sep 24, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@devnjw
Copy link
Contributor

devnjw commented Sep 24, 2024

To Reproduce

git clone https://github.com/devnjw/fumadocs
cd fumadocs
pnpm install
pnpm build

Current vs. Expected behavior

With pnpm build I got following error:

...

SyntaxError: Bad control character in string literal in JSON at position 1143
    at JSON.parse (<anonymous>)
    at 66214 (/Users/jinwoo/gits/test/fd-test/.next/server/chunks/6214.js:1:138)
    at Function.t (/Users/jinwoo/gits/test/fd-test/.next/server/webpack-runtime.js:1:143) {
  digest: '3675251263'
}
SyntaxError: Bad control character in string literal in JSON at position 1143
    at JSON.parse (<anonymous>)
    at 66214 (/Users/jinwoo/gits/test/fd-test/.next/server/chunks/6214.js:1:138)
    at Function.t (/Users/jinwoo/gits/test/fd-test/.next/server/webpack-runtime.js:1:143) {
  digest: '3675251263'
}

Error occurred prerendering page "/docs/buy-museum-tickets". Read more: https://nextjs.org/docs/messages/prerender-error

SyntaxError: Bad control character in string literal in JSON at position 1143
    at JSON.parse (<anonymous>)
    at 66214 (/Users/jinwoo/gits/test/fd-test/.next/server/chunks/6214.js:1:138)
    at Function.t (/Users/jinwoo/gits/test/fd-test/.next/server/webpack-runtime.js:1:143)
 ✓ Generating static pages (8/8)

> Export encountered errors on following paths:
	/docs/[[...slug]]/page: /docs/buy-museum-tickets
 ELIFECYCLE  Command failed with exit code 1.

I expected build successfully.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 20.12.2
  npm: 10.5.0
  Yarn: 1.22.19
  pnpm: 9.3.0
Relevant Packages:
  next: 14.2.13 // Latest available version is detected (14.2.13).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.6.2
Next.js Config:
  output: N/A

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

Integrations (e.g OpenAPI, Typescript DocsGen)

Additional context

I created project with command pnpm create fumadocs-app.
Then I intergrated OpenAPI following the document.
pnpm dev works, but pnpm build fails.

I've used museum.yaml example for reproduction

@devnjw devnjw added the bug Something isn't working label Sep 24, 2024
@devnjw devnjw changed the title Build fail - SyntaxError: Bad control character in string literal in JSON at position 1143 APIPage Build fail - SyntaxError: Bad control character in string literal in JSON at position 1143 Sep 24, 2024
@fuma-nama
Copy link
Owner

Confirmed an upstream issue from Shiki, installing Shiki to your workspace with pnpm i shiki can fix the issue (probably due to some logic of Next.js bundler)

@devnjw
Copy link
Contributor Author

devnjw commented Sep 25, 2024

Thank you!

@kyungmin-yoo
Copy link

@fuma-nama thanks you for your solution. We'll try it as you suggested.

@fuma-nama
Copy link
Owner

See: shikijs/shiki#784
Will recommend to install Shiki to your workspace for now.

songkeys added a commit to RSS3-Network/Docs that referenced this issue Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants