Missing "vite-manifest.json" file on build
Describe the bug
Building a SvelteKit application on one of my GitLab runners breaks with:
[vite-plugin-svelte-compile] ENOENT: no such file or directory, open '.../.svelte-kit/output/client/vite-manifest.json'
On my local machine, the build is fine. I was curious about the vite-manifest.json file, and it looks like it's actually generated:
✓ 1268 modules transformed.
.svelte-kit/output/client/_app/version.json 0.03 kB │ gzip: 0.05 kB
.svelte-kit/output/client/vite-manifest.json 38.84 kB │ gzip: 2.79 kB
...
But if I go inspect that folder after the build is complete, that file isn't present. Does it get deleted at some point? Is there any chance of a race condition happening?
The exact line that spawns the error is:
https://github.com/sveltejs/kit/blob/e8d8587120cf3d27ff029f1f2113f8c3c1217b5b/packages/kit/src/exports/vite/index.js#L717
Reproduction
I don't know how to reproduce this, it's only happening on a system I don't control.
Logs
No response
System Info
System doesn't have external internet access, but it's using:
@sveltejs/adapter-static: 2.0.2
@sveltejs/kit: 1.15.7
svelte: 3.58.0
vite: 4.3.2
Severity
blocking all usage of SvelteKit
Additional Information
Apologies for the lack of a good reproduction, more so just trying to understand where to continue debugging the issue.
Is the ... an absolute path replaced or was it actually there in the message?
Is the ... an absolute path replaced or was it actually there in the message?
An absolute path replaced for privacy, apologies if that was confusing.
Check if the issue occurs in a new blank project deployed on GitLab.
Check if the issue occurs in a new blank project deployed on GitLab.
Sorry for the long delay -- yes, the problem also occurs with the default starter SvelteKit app.
Again the Vite build log is saying that a vite-manifest.json file is being created, but it's not being found. Locally, where the build does work, I'm also not seeing a vite-manifest.json file in my build output. Do you know what's going on with that file?
I'm also not seeing a vite-manifest.json file in my build output. Do you know what's going on with that file?
It's removed after the build is done so that's expected at least but I don't see why it'd behave differently on GitLab.
https://github.com/sveltejs/kit/blob/a7bffde62c3058db11c69f4c4250dda99674a1dc/packages/kit/src/exports/vite/index.js#L797
The plugin name from the error, vite-plugin-svelte-compile is odd, the name's not used in either SvelteKit or vite-plugin-svelte, are you using any others?
The plugin name from the error, vite-plugin-svelte-compile is odd, the name's not used in either SvelteKit or vite-plugin-svelte, are you using any others?
Isn't this it?
https://github.com/sveltejs/kit/blob/a7bffde62c3058db11c69f4c4250dda99674a1dc/packages/kit/src/exports/vite/index.js#L477-L479
It's the same error on the demo project, with nothing extra added.
I'm wondering if there's a race condition happening, because in the logs I do see the "done ..." lines from the build output at the same time the error appears. So it seems as though the build completes, but then that last plugin is running too late to still have the vite-manifest.json file around?
@gtm-nayan Is there any more information I can give to help with this? It looks like the “awaiting submitter” tag is still applied.
Ah sorry, I forgot to send the comment I had typed out.
The plugin name is missing kit in the error message in your original post, was that missed out when pasting or does the actual error report the plugin as vite-plugin-svelte-compile? There shouldn't be a race condition since the function that deletes the files is only called after everything has completed.
The plugin name is missing
kitin the error message in your original post, was that missed out when pasting or does the actual error report the plugin asvite-plugin-svelte-compile?
Ah, sorry, I did copy it over incorrectly. The error does reference vite-plugin-sveltekit-compile.
The relevant part of the build log I see is:
> Using @sveltejs/adapter-static
Wrote site to "build"
✓ done
✓ built in 8.44s
[vite-plugin-sveltekit-compile] ENOENT: no such file or directory, open '.../.svelte-kit/output/client/vite-manifest.json'
✓ built in 12.77s
error during build:
Error: ENOENT: no such file or directory, open '.../.svelte-kit/output/client/vite-manifest.json'
at ...
The full path of the error uses a mix of / and \, which I assume is okay:
ENOENT: no such file or directory, open 'C:\gitlab-runner-XXX\builds\YYY\0\ZZZ\repo-name\.svelte-kit/output/client/vite-manifest.json'
The double ✓ built in ... lines confuse me a bit -- is there any reason that would happen? Locally I don't see that issue at all, and my GitLab CI file is just running the usual npm run build.
The double built in lines are for the two vite client and server builds I think which should be fine. Although the logs seem out of order, I'm confused why the adapter log would show up above the others when it should be at the end.
Could you please share the blank project that reproduced the issue on gitlab with the CI scripts configured?
They both seem to be associated with the server build, curiously:
.svelte-kit/output/client/_app/version.json ...
.svelte-kit/output/client/vite-manifest.json ...
...
✓ built in 2.28s
.svelte-kit/output/server/vite-manifest.json ...
...
.svelte-kit/output/server/index.js ...
Run npm run preview to preview your production build locally.
> Using @sveltejs/adapter-static
Wrote site to "build"
✓ done
✓ built in 8.44s
[vite-plugin-sveltekit-compile] ENOENT: no such file or directory, open '.../.svelte-kit/output/client/vite-manifest.json'
✓ built in 12.77s
error during build:
Error: ENOENT: no such file or directory, open '.../.svelte-kit/output/client/vite-manifest.json'
at ...
It almost seems as though something in the server build is trying to happen twice?
The blank project used is the default Sverdle app with nothing extra enabled. The CI is a little funky because the system doesn't have internet access, so it's copying a pre-populated set of node modules over:
image: node:latest
.deploy-template:
stage: deploy
script:
- "if (-not (Test-Path: P:\\)) { net use P: \\\\drive\\name\folder }"
- $env:NODE_HOME = "P:\\software\\<path>\\node\\node-19.6.1"
- $env:PATH = "$env:NODE_HOME;$env:PATH"
- cp "P:\\software\\<path>\\node_modules_archive.zip" .
- Expand-Archive -Path "node_modules_archive.zip"
- mv node_modules_archive/node_modules node_modules
- npm run build
- mv build public
artifacts:
paths:
- public
when: always
tags:
- executor:powershell
pages:
extends: [.deploy-template]
only:
- main
(Copied over manually, so may have typos.)
Somewhat unsurprisingly, if I comment out the following lines:
https://github.com/sveltejs/kit/blob/a7bffde62c3058db11c69f4c4250dda99674a1dc/packages/kit/src/exports/vite/index.js#L796-L798
the build goes through just fine.
But, looking at the logs, the server build is run twice...
I have the same issue here. It's happening with Ionic Extension for VS Code when you want to run application in Android Emulator in combination with Capacitor. And it happens only there and only if the application was already built once using the extension, the first run works just fine for me. If I just close VS Code and run the application is going to be built just fine. Also if I run application via npx cap run android it runs just fine.
One workaround for now that I suggest is that you use npx cap run android whenever run is not working using Ionic Extension. When the app is running you can still attach the debugger using Ionic extension if you need it.
That’s interesting, but my use case is entirely different since I’m seeing the issue in a GitLab runner, not within the VS Code terminal.
@gtm-nayan Do you have any idea why the server build might run twice under any circumstances?
Same issue here on VSCode with internet access and node adapter.
Same issue here on VSCode with internet access and node adapter.
If you rewind the kit/Vite packages a few versions, how far back do you have to go before the deployment works?
Just adding my comment as I have this issue as well. (Windows 11, Svelte 3.59.2, Kit 1.22.3, Adapter-Static 2.0.3, Vite 4.4.7, currently using Node 16.18.1)
I have a very simple, default setup to build a non-SPA static site. The build process does successfully complete and then the error pops up just as described in the original issue above. For what it's worth, I don't see the issue when running the site with "vite dev"
I don't remember this being an issue when I first setup Svelte for my project, originally with Svelte 3.54.0, Kit 1.0.13, Adapter-Static 1.0.1 and Vite 4.0.0.
Edit: Did testing and figured out where the issue begin. See next post...
Okay, summary of results from testing:
- The issue appears to have been introduced with SvelteKit v1.3.1
- The issue does NOT occur with SvelteKit v1.3.0 regardless of Svelte or Vite versions.
If you want to test it out yourself, here's a snippet from package.json for an environment that works correctly (no error):
"@sveltejs/adapter-auto": "^2.1.0",
"@sveltejs/adapter-static": "^1.0.6",
"@sveltejs/kit": "^1.3.0",
"svelte": "^3.59.2",
"svelte-preprocess": "^5.0.4",
"vite": "^4.4.7"
And one that does NOT work, outputting the error originally reported:
"@sveltejs/adapter-auto": "^2.1.0",
"@sveltejs/adapter-static": "^1.0.6",
"@sveltejs/kit": "^1.3.1",
"svelte": "^3.59.2",
"svelte-preprocess": "^5.0.4",
"vite": "^4.4.7"
You'll see that the only difference is SvelteKit. Note that adapter-static is capped at v1.0.6 for SvelteKit v1.3.0. Hope this helps solve the mystery.
Edit: Narrowed-in on exact minor versions from further testing
I also noticed that one of the pull requests from 1.3.1 ( https://github.com/sveltejs/kit/pull/8636 ) mentioned in the 1.3.1 release notes contains changes directly related to where the manifest file is loaded from. Might be a good starting point. Hope that helps.
Thanks @kiddailey
Can confirm when running npm install @sveltejs/[email protected] and then trying npm run build again it works fine!
Same for me, locking kit at 1.3.0 and adapter-static at 1.0.6 fixes the issue.
@Rich-Harris Sorry for the ping, but as the author of #8636 do you have any ideas about why it might be causing the server build to run twice under certain circumstances?