pnpm build遇到错误,如何解决?
hi.
$ pnpm build
[email protected] build C:\Users\12799\urara run-s tsc urara:build kit:build clean
[email protected] tsc C:\Users\12799\urara tsc -p tsconfig.node.json
[email protected] urara:build C:\Users\12799\urara node urara.js build
08:23:38 [urara] make dir static 08:23:38 [urara] make dir src/static 08:23:38 [urara] make dir src\routes\assets 08:23:38 [urara] make dir static\assets 08:23:38 [urara] make dir src\static\assets 08:23:38 [urara] make dir static\hello-world 08:23:38 [urara] make dir src\routes\hello-world 08:23:38 [urara] make dir src\static\hello-world 08:23:38 [urara] make dir src\routes\hello-world\elements 08:23:38 [urara] make dir static\hello-world\elements 08:23:38 [urara] make dir src\static\hello-world\elements 08:23:39 [urara] make dir src\routes\hello-world\toc-disabled 08:23:39 [urara] copy file src\routes\hello-world+page.svelte.md 08:23:39 [urara] make dir static\hello-world\toc-disabled 08:23:39 [urara] make dir src\static\hello-world\toc-disabled 08:23:39 [urara] copy file static\assets\[email protected] 08:23:39 [urara] copy file static\assets\[email protected] 08:23:39 [urara] copy file static\favicon.png 08:23:39 [urara] copy file static\assets\[email protected] 08:23:39 [urara] copy file static\assets\[email protected] 08:23:39 [urara] copy file src\routes\hello-world\elements+page.svelte.md 08:23:39 [urara] copy file static\hello-world\urara.webp 08:23:39 [urara] copy file src\routes\hello-world\toc-disabled+page.md 08:23:39 [urara] copy file static\assets\[email protected]
[email protected] kit:build C:\Users\12799\urara cross-env NODE_OPTIONS=--max_old_space_size=7680 vite build
vite v5.1.1 building SSR bundle for production... transforming (80) node_modules.pnpm@[email protected]_@sveltejs+vite-plu 🌼 daisyUI 4.6.2 ├─ ✔︎ 12 themes added https://daisyui.com/docs/themes ╰─ ❤︎ Support daisyUI project: https://opencollective.com/daisyui
🌼 daisyUI 4.6.2 ├─ ✔︎ 12 themes added https://daisyui.com/docs/themes ╰─ ★ Star daisyUI on GitHub https://github.com/saadeghi/daisyui
transforming (119) src\lib\components\prose\img.svelte08:23:48 [vite-plugin-svelte] C:/Users/12799/urara/src/lib/components/post_toc.svelte:54:10 A11y: with click handler must have an ARIA role
52: <li class='flex flex-col' id={toc-item-${slug}}>
53:
54: <span
^
55: class="cursor-pointer border-l-4 border-transparent transition-all hover:border-primary hover:bg-base-content hover:bg-opacity-10 active:bg-primary active:text-primary-content active:font-bold pr-4{depth
56: <= 2
✓ 166 modules transformed.
rendering chunks (27)...(node:22100) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use node --trace-deprecation ... to show where the warning was created)
vite v5.1.1 building for production...
transforming (103) src\lib\config\general.ts08:23:55 [vite-plugin-svelte] C:/Users/12799/urara/src/lib/components/post_toc.svelte:54:10 A11y: with click handler must have an ARIA role
52: <li class='flex flex-col' id={toc-item-${slug}}>
53:
54: <span
^
55: class="cursor-pointer border-l-4 border-transparent transition-all hover:border-primary hover:bg-base-content hover:bg-opacity-10 active:bg-primary active:text-primary-content active:font-bold pr-4{depth
56: <= 2
✓ 135 modules transformed.
.svelte-kit/output/client/_app/version.json
0.03 kB │ gzip: 0.05 kB
.svelte-kit/output/client/.vite/manifest.json
6.10 kB │ gzip: 0.97 kB
.svelte-kit/output/client/_app/immutable/assets/urara.CoHjeEFW.avif
12.61 kB
.svelte-kit/output/client/_app/immutable/assets/favicon.DiqaJUa5.avif
23.00 kB
.svelte-kit/output/client/_app/immutable/assets/posts.D4gQgZwN.css
0.44 kB │ gzip: 0.23 kB
.svelte-kit/output/client/_app/immutable/assets/0.C9CoXRIv.css
106.91 kB │ gzip: 18.62 kB
.svelte-kit/output/client/_app/immutable/entry/start.CHzI6prP.js
0.07 kB │ gzip: 0.08 kB
.svelte-kit/output/client/_app/immutable/chunks/stores.CNSca7nU.js
0.23 kB │ gzip: 0.17 kB
.svelte-kit/output/client/_app/immutable/chunks/posts.4dVmwM_k.js
0.30 kB │ gzip: 0.23 kB
.svelte-kit/output/client/_app/immutable/chunks/index.BI7v63FY.js
0.45 kB │ gzip: 0.32 kB
.svelte-kit/output/client/_app/immutable/nodes/1.Y113fK_j.js
0.84 kB │ gzip: 0.52 kB
.svelte-kit/output/client/_app/immutable/chunks/preload-helper.BQ24v_F8.js
0.91 kB │ gzip: 0.56 kB
.svelte-kit/output/client/_app/immutable/nodes/5.C-yPLSwo.js
2.20 kB │ gzip: 1.15 kB
.svelte-kit/output/client/app/immutable/chunks/posts.DhIe2gb.js
2.49 kB │ gzip: 1.26 kB
.svelte-kit/output/client/_app/immutable/chunks/scheduler.FGUOCI5T.js
2.77 kB │ gzip: 1.32 kB
.svelte-kit/output/client/_app/immutable/nodes/3.3R-IqVJ9.js
4.66 kB │ gzip: 1.90 kB
.svelte-kit/output/client/_app/immutable/chunks/workbox-window.prod.es5.DFjpnwFp.js 5.29 kB │ gzip: 2.19 kB
.svelte-kit/output/client/_app/immutable/entry/app.B2cl9_uC.js
5.90 kB │ gzip: 2.20 kB
.svelte-kit/output/client/_app/immutable/chunks/post_layout.BG0AmA4i.js
10.75 kB │ gzip: 4.11 kB
.svelte-kit/output/client/_app/immutable/chunks/index.TPYxZWDS.js
11.46 kB │ gzip: 4.90 kB
.svelte-kit/output/client/_app/immutable/nodes/2.DhDS65G0.js
14.27 kB │ gzip: 5.26 kB
.svelte-kit/output/client/_app/immutable/nodes/0.DN7NveTH.js
24.89 kB │ gzip: 8.21 kB
.svelte-kit/output/client/_app/immutable/chunks/entry.BNfZGwt4.js
26.53 kB │ gzip: 10.52 kB
.svelte-kit/output/client/_app/immutable/nodes/4.DNb5CQOP.js
32.18 kB │ gzip: 11.28 kB
.svelte-kit/output/client/_app/immutable/chunks/post_card.CJDnxPmc.js
59.80 kB │ gzip: 17.32 kB
Browserslist: caniuse-lite is outdated. Please run:
npx update-browserslist-db@latest
Why you should do it regularly: https://github.com/browserslist/update-db#readme
PWA v0.17.5 mode generateSW precache 68 entries (710.83 KiB) files generated .svelte-kit\output\client\sw.js .svelte-kit\output\client\workbox-f3e6b16a.js warnings One of the glob patterns doesn't match any files. Please remove or fix the following: { "globDirectory": ".svelte-kit/output", "globPattern": "posts.json", "globIgnores": [ "/sw*", "/workbox-", "client/sw.js", "client/workbox-.js" ] } One of the glob patterns doesn't match any files. Please remove or fix the following: { "globDirectory": ".svelte-kit/output", "globPattern": "prerendered//*.html", "globIgnores": [ "/sw*", "**/workbox-", "client/sw.js", "client/workbox-.js" ] }
✓ built in 9.24s SvelteKitError: Not found: /elements at resolve2 (file:///C:/Users/12799/urara/.svelte-kit/output/server/index.js:3431:18) at resolve (file:///C:/Users/12799/urara/.svelte-kit/output/server/index.js:3263:34) at Object.handle (file:///C:/Users/12799/urara/.svelte-kit/output/server/chunks/hooks.server.js:2:52) at respond (file:///C:/Users/12799/urara/.svelte-kit/output/server/index.js:3261:43) { status: 404, text: 'Not Found' } SvelteKitError: Not found: /toc-disabled at resolve2 (file:///C:/Users/12799/urara/.svelte-kit/output/server/index.js:3431:18) at resolve (file:///C:/Users/12799/urara/.svelte-kit/output/server/index.js:3263:34) at Object.handle (file:///C:/Users/12799/urara/.svelte-kit/output/server/chunks/hooks.server.js:2:52) at respond (file:///C:/Users/12799/urara/.svelte-kit/output/server/index.js:3261:43) { status: 404, text: 'Not Found' }
node:internal/event_target:1101
process.nextTick(() => { throw err; });
^
Error: 404 /elements (linked from /)
To suppress or handle this error, implement handleHttpError in https://kit.svelte.dev/docs/configuration#prerender
at file:///C:/Users/12799/urara/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_@types+node@2_koq3ersix6ahwrpqcmv22k3req/node_modules/@sveltejs/kit/src/core/config/options.js:202:13
at file:///C:/Users/12799/urara/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_@types+node@2_koq3ersix6ahwrpqcmv22k3req/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:65:25
at save (file:///C:/Users/12799/urara/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_@types+node@2_koq3ersix6ahwrpqcmv22k3req/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:403:4)
at visit (file:///C:/Users/12799/urara/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_@types+node@2_koq3ersix6ahwrpqcmv22k3req/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:236:3)
Node.js v23.3.0 ELIFECYCLE Command failed with exit code 1. ERROR: "kit:build" exited with 1. ELIFECYCLE Command failed with exit code 1.
谢谢回复。
从构建日志看上去,导致构建出现错误的原因是
Error: 404 /elements (linked from /)
能从主页链接到这个演示文章的地方,就只有站点设定的标题栏链接了,请检查一下您的 src/lib/config/general.ts 文件,这个部分的配置方法可见 配置 | Urara Docs
或许您是想测试一下怎么修改标题栏的链接,不过 elements 和 toc-disabled 这两篇演示文章的默认位置是在 /urara/hello-world 目录中,想要将标题栏的按钮对应的链接修改为演示的 elements 和 toc-disabled 文章,请参考以下片段
export const header: HeaderConfig = {
nav: [
{
text: 'Elements', // 标题栏按钮显示的文字
link: '/hello-world/elements' // 根据文章实际路径添加 /hello-world 前缀
},
{
text: 'ToC Disabled',
link: '/hello-world/toc-disabled'
}
]
}
hi @briteming ,Interstellar750 的回答解决了你的问题吗? 如果没有其它问题,我将在一天后关闭此 issue。
hi. @kwaa ,没有解决。我没看懂。能告知如何详细修复这个问题吗?
没有解决。我没看懂。能告知如何详细修复这个问题吗?
SvelteKit 内置的链接检测报错,你需要按照上面的说明修改(或删除) src/lib/config/general.ts 中对应的 header.nav 配置。
hi. @kwaa ,没有解决。我没看懂。能告知如何详细修复这个问题吗?
或许是我的说明还不够详细,请先找到 src/lib/config/general.ts 文件
这是一个目录到文件的链接,找到您的 Urara 项目的文件夹,依次打开其中的
src>lib>config文件夹,依次打开到最后的config目录后,您会在该目录中看到一个名为general.ts的文件
如果您想尝试自己修改,您需要使用编辑器打开它,并向下滚动,直到您找到类似下方代码框中的内容,这些内容大概在文件的 50 至 70 行之间:
export const header: HeaderConfig = {
nav: [
{
link: '/hello-world',
text: 'Get Started',
},
{
link: '/hello-world/elements',
text: 'Elements',
},
],
}
之后您就可以按照我的 上一个回复 来进行修改
或者您也可以将您的整个名为 general.ts 的文件发送到评论中,这样我可以明确知道问题出在哪里并协助您进行修改
@Interstellar750
$ cat src/lib/config/general.ts import type { DateConfig, FeedConfig, FooterConfig, HeadConfig, HeaderConfig, ThemeConfig } from '$lib/types/general'
export const theme: ThemeConfig = [ { name: 'cmyk', text: '🖨 Light', }, { name: 'dracula', text: '🧛 Dark', }, { name: 'valentine', text: '🌸 Valentine', }, { name: 'aqua', text: '💦 Aqua', }, { name: 'synthwave', text: '🌃 Synthwave', }, { name: 'night', text: '🌃 Night', }, { name: 'lofi', text: '🎶 Lo-Fi', }, { name: 'lemonade', text: '🍋 Lemonade', }, { name: 'cupcake', text: '🧁 Cupcake', }, { name: 'garden', text: '🏡 Garden', }, { name: 'retro', text: '🌇 Retro', }, { name: 'black', text: '🖤 Black', }, ]
export const head: HeadConfig = {}
export const header: HeaderConfig = { nav: [ { link: '/hello-world', text: 'Get Started', }, { link: '/hello-world/elements', text: 'Elements', }, { text: 'ToC Disabled', link: '/hello-world/toc-disabled' } ], }
export const footer: FooterConfig = { nav: [ { link: '/atom.xml', text: 'Feed', }, { link: '/sitemap.xml', text: 'Sitemap', }, ], }
export const date: DateConfig = { locales: 'en-US', options: { day: 'numeric', month: 'short', weekday: 'long', year: '2-digit', }, }
export const feed: FeedConfig = {} ~/urara (main)$
看看如何修改? 谢谢你
根据您提供的文件,似乎您并没有对 general.ts 文件进行什么修改,问题并不出现在这个文件中
或许您需要提供一下整个仓库的文件,以方便我们定位问题
您可以将整个仓库进行压缩打包上传,或者使用 Git 来上传到 GitHub,我会检查其中的问题
我就是从https://github.com/importantimport/urara/ 克隆下来的: git clone https://github.com/importantimport/urara/ cd urara
所以我克隆下来的仓库就是你们这个urara仓库。难道克隆下来后,会发生什么变化吗?不可能啊
我运行 pnpm dev, 则正常。
根据您的描述,这似乎是一个 Windows 系统下的问题,由于我手头暂时没有 Windows 的设备,目前没法帮您排除问题
哦,我登录linux vps,这次运行pnpm build没问题了.
可见windows就是个坑。我还一直以为你们的程序有问题
要是你哪天重回windows的怀抱,麻烦排除一下windows下的问题
在我进行了一些尝试后,我觉得这应该是 Windows 系统上的路径分隔符 \ (反斜杠) 与 Unix 类系统上的路径分隔符 / (正斜杠) 导致的问题
会造成这个问题的文件有两个,分别是 post_card.svelte#L94 和 post_status.svelte#L22,它们都使用了 Urara.Post 这个命名空间中的 path 字段
因为前面提到的 Windows 系统上的路径分隔符 \ (反斜杠),那项目中的三篇文章,就渲染成了错误的路径:
/hello-world > href="\hello-world"
/hello-world/elements > href="\hello-world\elements"
/hello-world/toc-disabled > href="\hello-world\toc-disabled"
而使用 pnpm dev 来进行测试时,我从网页控制台看了一下链接,确实还是 Windows 系统的反斜杠,只是因为没有链接检查所以不会失败退出,而浏览器中能够访问大概是因为会自动转换