question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

esbuild: Unterminated string literal when building SSR bundle

See original GitHub issue

Describe the bug

This is an issue that first appeared for me 2 days ago, where all builds would fail because of a seemingly incomplete import statement in one specific file, where no such import statement existed. This could be fixed by deleting the file, starting the devserver, then adding the file back in while it’s running. This workaround, however as far as I know, is not practical when deploying to Vercel in this case, as it would probably take a script to run the dev server with the file deleted, then subsequently readding it.

To the best of my knowledge, this does not have anything to do with vite, since I was unable to reproduce it with the SSR projects provided.

Reproduction

A copy of the project is on https://github.com/murl-digital/draconium.productions-mirror, and the problem has to do with /src/routes/index.svelte.

Logs

vite v2.8.3 building SSR bundle for production...
✘ [ERROR] Unterminated string literal
    html:/vercel/path0/src/routes/index.svelte:21:8:
      21 │ import "
         ╵         ^
> Build failed with 1 error:
html:/vercel/path0/src/routes/index.svelte:21:8: ERROR: Unterminated string literal
html:/vercel/path0/src/routes/index.svelte:21:8: ERROR: Unterminated string literal
    at failureErrorWithLog (/vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:1602:15)
    at /vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:1248:28
    at runOnEndCallbacks (/vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:1033:63)
    at buildResponseToResult (/vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:1246:7)
    at /vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:1355:14
    at /vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:665:9
    at handleIncomingPacket (/vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:762:9)
    at Socket.readFromStdout (/vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:632:7)
    at Socket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:293:12)

System Info

Unable to run on Vercel, but here’s my local machine where I also encountered this bug on.

System:
    OS: Windows 10 10.0.22000
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
    Memory: 38.76 GB / 63.92 GB
  Binaries:
    Node: 17.4.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.3.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (98.0.1108.55)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    @sveltejs/adapter-vercel: next => 1.0.0-next.43
    @sveltejs/kit: next => 1.0.0-next.278
    svelte: ^3.46.4 => 3.46.4
    vite: ^2.8.3 => 2.8.3

Severity

blocking all usage of SvelteKit

Additional Information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
murl-digitalcommented, Mar 7, 2022

As ben said, thanks @CaptainCodeman! The fix works perfectly and I’ve had no other issues

1reaction
benmccanncommented, Mar 7, 2022

Thanks @CaptainCodeman! That investigation sped things up for me quite a bit. I sent a fix for the issue here: https://github.com/vitejs/vite/pull/7202

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: unterminated string literal - JavaScript | MDN
The JavaScript error "unterminated string literal" occurs when there is an unterminated string literal somewhere. String literals must be enclosed by single ( ......
Read more >
javascript - Common sources of unterminated string literal
I am trying to debug a JavaScript script that gets read in a Firefox extension and executed. I only can see errors via...
Read more >
“esbuild-register The "path" argument must be of type string ...
“esbuild-register The "path" argument must be of type string. Received undefined” Code Answer. the path argument must be of type string.
Read more >
storybookjs/storybook (Raised $170.00) - Issuehunt
[Bug]: esbuild fails with `ERROR: Invalid option in build() call: ... [Vue warn]: Invalid VNode type: button (string) when writing TSX syntax.
Read more >
仕事ですぐに使えるTypeScript - フューチャー技術ブログ
build : ビルドが必要なライブラリではビルドを実行して配布できるようにする ... error TS1002: Unterminated string literal.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found