kit: RollupError: Unexpected character '�'
Describe the bug
After upgrading to sveltekit 2, I am getting this error:
> Using @sveltejs/adapter-node
error during build:
RollupError: Unexpected character '�'
at error (file:///...node_modules/rollup/dist/es/shared/parseAst.js:337:30)
at nodeConverters (file:///...node_modules/rollup/dist/es/shared/parseAst.js:2084:9)
at convertNode (file:///...node_modules/rollup/dist/es/shared/parseAst.js:969:12)
at convertProgram (file:///...node_modules/rollup/dist/es/shared/parseAst.js:960:48)
at parseAstAsync (file:///...node_modules/rollup/dist/es/shared/parseAst.js:2150:20)
at async Module.tryParseAsync (file:///...node_modules/rollup/dist/es/shared/node-entry.js:13513:21)
at async Module.setSource (file:///...node_modules/rollup/dist/es/shared/node-entry.js:13094:35)
at async ModuleLoader.addModuleSource (file:///...node_modules/rollup/dist/es/shared/node-entry.js:17757:13)
I have no idea what unicode character is that supposed to be.
Reproduction
No idea how to reproduce yet. If someone can guide me on how to print verbose logs, that would be helpful! That way I can pinpoint which source exactly is it failing to parse
Logs
No response
System Info
System:
OS: macOS 14.2
CPU: (8) arm64 Apple M1 Pro
Memory: 66.70 MB / 16.00 GB
Shell: 3.6.0 - /opt/homebrew/bin/fish
Binaries:
Node: 20.3.0 - ~/.local/share/nvm/v20.3.0/bin/node
Yarn: 1.22.19 - ~/.local/share/nvm/v20.3.0/bin/yarn
npm: 9.6.7 - ~/.local/share/nvm/v20.3.0/bin/npm
pnpm: 8.10.2 - ~/.local/share/nvm/v20.3.0/bin/pnpm
bun: 1.0.0 - ~/.bun/bin/bun
Watchman: 2023.11.27.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 120.0.6099.109
Safari: 17.2
npmPackages:
@sveltejs/adapter-node: ^2.0.1 => 2.0.1
@sveltejs/kit: ^2.0.4 => 2.0.4
@sveltejs/vite-plugin-svelte: ^3.0.1 => 3.0.1
svelte: ^4.2.8 => 4.2.8
vite: ^5.0.10 => 5.0.10
Severity
blocking an upgrade
Additional Information
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (2 by maintainers)
@multiplehats @rbozan @bartvdbraak This issue has something to do with vite trying to bundle the rust binary that resvg uses (resvg-js is server-side only for this reason). I overcame this issue using the approach outlined in this resvg-js issue. Install
@resvg/resvg-jsas a non-dev dependency, then add this section in your vite.config.js/ts:With sveltekit-og, you’ll also encounter another issue related to using svelte/compiler and one of its dependencies. This comment on a related issue provides some snippets that hopefully help when using sveltekit-og under adapter-node.
In my case, I was using
@node-rs/argon2. The logging mentioned in https://github.com/sveltejs/kit/issues/11416#issuecomment-1980805816 helped track this downI had to move
@node-rs/argon2from mydevDependenciesto mydependencieswithinpackage.json. Then add the following to myvite.config.ts:I’m having the same issue but am not using
resvg. Any ideas how how to get Rollup to mention the file where the character was encountered?Edit: Rollup 4.13.0 is said to know mention the file that the character was found in, though I haven’t been able to get that to work. The following addition to one of the files in
node_modulehas helped me find out which file it was however:node_modules/rollup/dist/es/shared/parseAst.js:374:… this will print the path to the offending file above the build error.
I had Oslo as my dependency, and this to vite.config didn’t help.
What worked was explicitly adding
@node-rs/argon2to dependenciesGod bless your soul