gpt4 book ai didi

github-pages - 尝试在 github 页面上部署我的 svelte 应用程序时如何修复此错误?

转载 作者:行者123 更新时间:2023-12-05 05:36:53 26 4
gpt4 key购买 nike

我正在尝试在 GitHub Pages 上部署我的 svelte 应用程序,但无法摆脱运行“npm run build”时遇到的这些错误。

确切的错误是:

(node:15364) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time
file:///C:/Isabella/personal-website/node_modules/@sveltejs/kit/dist/prerender.js:460
throw new Error(format_error(details, config));
^
Error: 404 /src/images/github.png (linked from /)
at file:///C:/Isabella/personal-website/node_modules/@sveltejs/kit/dist/prerender.js:460:11
at save (file:///C:/Isabella/personal-website/node_modules/@sveltejs/kit/dist/prerender.js:744:4)
at visit (file:///C:/Isabella/personal-website/node_modules/@sveltejs/kit/dist/prerender.js:635:3)
[vite-plugin-svelte-kit] Prerendering failed with code 1
error during build:
Error: Prerendering failed with code 1
at ChildProcess.<anonymous> (file:///C:/Isabella/personal-website/node_modules/@sveltejs/kit/dist/vite.js:2367:14)
at ChildProcess.emit (node:events:527:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)

这是我的 svelte.config.js 文件:

import preprocess from 'svelte-preprocess';
import adapter from '@sveltejs/adapter-static';

/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: preprocess(),
kit: {
// target: '#svelte',
adapter: adapter({
pages: 'build', // path to public directory
assets: 'build', // path to public directory
fallback: null,
}),
prerender: {
// This can be false if you're using a fallback (i.e. SPA mode)
default: true
}
}
};

export default config;

最佳答案

问题是您在 index.svelte 中链接到 /src/images/github.png 但预渲染器找不到该文件,因为它尝试在默认 Assets 文件夹 static 中查找文件。

要修复它,请将链接更改为正确的路径并将图像放在静态文件夹中(即 images/github.png 如果您将图像文件夹放在静态文件夹中)。

关于github-pages - 尝试在 github 页面上部署我的 svelte 应用程序时如何修复此错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73230057/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com