Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble on build with vite and sveltejs/kit #9045

Closed
LuticaCANARD opened this issue Feb 14, 2023 · 9 comments · Fixed by #9053
Closed

Trouble on build with vite and sveltejs/kit #9045

LuticaCANARD opened this issue Feb 14, 2023 · 9 comments · Fixed by #9053
Milestone

Comments

@LuticaCANARD
Copy link

LuticaCANARD commented Feb 14, 2023

Describe the bug

When I execute npm run build, I got a trouble about compile like that :


file:///D:/{project route}/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:269
                                enqueue(decoded, decodeURI(pathname), pathname);
                                                 ^

URIError: URI malformed
    at decodeURI (<anonymous>)
    at visit (file:///D:/{project route}/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:269:22)

Node.js v18.13.0
[vite-plugin-sveltekit-compile] Failed with code 1
error during build:
Error: Failed with code 1
    at ChildProcess.<anonymous> (file:///D:/{project route}/node_modules/@sveltejs/kit/src/utils/fork.js:68:13)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)

Reproduction

https://stackblitz.com/edit/nodemon-qgnnoj?file=README.md

Logs

PS D:\{project route}> npm run build

> {proj}@0.0.1 build
> vite build


vite v4.1.1 building SSR bundle for production...
transforming (1) .svelte-kit\generated\server\internal.js오후 11:58:11 [vite-plugin-svelte] /src/routes/Header.svelte:43:12 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
41:     </div>
42:     <div id="mobile_menu" class="m_toggle_off">
43:             <div id="mobile_toggle_btn" class="buttons" on:click={()=>open_menubar_mobile()}>
                ^
44:       </div>
45:       <div id="mobile_menu_bar_wrap" class= "menu_bar_off">
✓ 75 modules transformed.
오후 11:58:12 [vite-plugin-svelte] ssr compile done.
package                 files     time     avg
{Proj}       10   54.8ms   5.5ms
@sveltejs/kit               1   16.4ms  16.4ms
s

vite v4.1.1 building for production...
transforming (16) node_modules\@sveltejs\kit\src\runtime\client\start.js오후 11:58:12 [vite-plugin-svelte] /src/routes/Header.svelte:43:12 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
41:     </div>
42:     <div id="mobile_menu" class="m_toggle_off">
43:             <div id="mobile_toggle_btn" class="buttons" on:click={()=>open_menubar_mobile()}>
                ^
44:       </div>
45:       <div id="mobile_menu_bar_wrap" class= "menu_bar_off">
✓ 92 modules transformed.
오후 11:58:12 [vite-plugin-svelte] dom compile done.
package                 files    time      avg
luneer-official-site       11   0.12s   10.7ms
.svelte-kit/output/client/_app/version.json                                                    0.03 kB
.svelte-kit/output/client/_app/immutable/assets/github-1ea8d62e.svg                            1.75 kB
.svelte-kit/output/client/_app/immutable/assets/svelte-logo-87df40b8.svg                       1.89 kB
.svelte-kit/output/client/vite-manifest.json                                                   9.86 kB
.svelte-kit/output/client/_app/immutable/assets/Lunear_main_mark-98c096ef.png                 52.72 kB
.svelte-kit/output/client/_app/immutable/assets/svelte-welcome-c18bcf5a.webp                 115.47 kB
.svelte-kit/output/client/_app/immutable/assets/svelte-welcome-6c300099.png                  360.81 kB
.svelte-kit/output/client/_app/immutable/assets/_page-08e4d5ca.css                             1.45 kB │ gzip:  0.53 kB
.svelte-kit/output/client/_app/immutable/assets/_layout-630f1e19.css                           3.50 kB │ gzip:  1.29 kB
.svelte-kit/output/client/_app/immutable/modules/pages/main/_page.js-ae5f4d3b.js               0.04 kB │ gzip:  0.06 kB
.svelte-kit/output/client/_app/immutable/chunks/environment-57be8769.js                        0.06 kB │ gzip:  0.07 kB
.svelte-kit/output/client/_app/immutable/modules/pages/_page.js-ed610ca4.js                    0.08 kB │ gzip:  0.09 kB
.svelte-kit/output/client/_app/immutable/modules/pages/_layout.js-7bef0f19.js                  0.11 kB │ gzip:  0.12 kB
.svelte-kit/output/client/_app/immutable/chunks/1-c56d921c.js                                  0.11 kB │ gzip:  0.11 kB
.svelte-kit/output/client/_app/immutable/modules/pages/slogan/_page.js-6ba60706.js             0.15 kB │ gzip:  0.13 kB
.svelte-kit/output/client/_app/immutable/modules/pages/about/_page.js-6ba60706.js              0.15 kB │ gzip:  0.13 kB
.svelte-kit/output/client/_app/immutable/modules/pages/projects/_page.js-6ba60706.js           0.15 kB │ gzip:  0.13 kB
.svelte-kit/output/client/_app/immutable/modules/pages/members/_page.js-6ba60706.js            0.15 kB │ gzip:  0.13 kB
.svelte-kit/output/client/_app/immutable/chunks/2-c183f0ee.js                                  0.18 kB │ gzip:  0.14 kB
.svelte-kit/output/client/_app/immutable/chunks/0-8ce6c74a.js                                  0.18 kB │ gzip:  0.14 kB
.svelte-kit/output/client/_app/immutable/chunks/4-71734198.js                                  0.18 kB │ gzip:  0.15 kB
.svelte-kit/output/client/_app/immutable/chunks/3-8c0a8442.js                                  0.19 kB │ gzip:  0.15 kB
.svelte-kit/output/client/_app/immutable/chunks/7-50a31139.js                                  0.19 kB │ gzip:  0.15 kB
.svelte-kit/output/client/_app/immutable/chunks/5-52b7961b.js                                  0.19 kB │ gzip:  0.15 kB
.svelte-kit/output/client/_app/immutable/chunks/6-9b580da7.js                                  0.19 kB │ gzip:  0.15 kB
.svelte-kit/output/client/_app/immutable/chunks/_page-a02d664f.js                              0.19 kB │ gzip:  0.17 kB
.svelte-kit/output/client/_app/immutable/chunks/_page-de0ef88a.js                              0.23 kB │ gzip:  0.18 kB
.svelte-kit/output/client/_app/immutable/components/pages/main/_page.svelte-417f4652.js        0.27 kB │ gzip:  0.20 kB
.svelte-kit/output/client/_app/immutable/chunks/_layout-5a4be12a.js                            0.30 kB │ gzip:  0.21 kB
.svelte-kit/output/client/_app/immutable/chunks/_page-cbe3748d.js                              0.32 kB │ gzip:  0.24 kB
.svelte-kit/output/client/_app/immutable/chunks/_page-34b026b6.js                              0.32 kB │ gzip:  0.24 kB
.svelte-kit/output/client/_app/immutable/chunks/_page-845e1d4b.js                              0.32 kB │ gzip:  0.24 kB
.svelte-kit/output/client/_app/immutable/chunks/_page-743fa2e6.js                              0.32 kB │ gzip:  0.24 kB
.svelte-kit/output/client/_app/immutable/chunks/stores-40b5108a.js                             0.49 kB │ gzip:  0.27 kB
.svelte-kit/output/client/_app/immutable/chunks/preload-helper-f8376bb0.js                     1.45 kB │ gzip:  0.66 kB
.svelte-kit/output/client/_app/immutable/components/error.svelte-21c5d381.js                   2.24 kB │ gzip:  0.83 kB
.svelte-kit/output/client/_app/immutable/chunks/index-a84fab65.js                              2.32 kB │ gzip:  0.84 kB
.svelte-kit/output/client/_app/immutable/chunks/singletons-6d36d066.js                         4.66 kB │ gzip:  1.73 kB
.svelte-kit/output/client/_app/immutable/components/pages/slogan/_page.svelte-6a8600d8.js      5.30 kB │ gzip:  1.46 kB
.svelte-kit/output/client/_app/immutable/components/pages/about/_page.svelte-6a8600d8.js       5.30 kB │ gzip:  1.46 kB
.svelte-kit/output/client/_app/immutable/components/pages/projects/_page.svelte-6a8600d8.js    5.30 kB │ gzip:  1.46 kB
.svelte-kit/output/client/_app/immutable/components/pages/members/_page.svelte-6a8600d8.js     5.30 kB │ gzip:  1.46 kB
.svelte-kit/output/client/_app/immutable/components/pages/_page.svelte-046d4d83.js            15.26 kB │ gzip:  3.83 kB
.svelte-kit/output/client/_app/immutable/chunks/index-7432af44.js                             18.07 kB │ gzip:  4.95 kB
.svelte-kit/output/client/_app/immutable/start-6655592f.js                                    71.77 kB │ gzip: 16.35 kB
.svelte-kit/output/client/_app/immutable/components/pages/_layout.svelte-f00c041f.js         111.17 kB │ gzip: 22.79 kB
s
file:///D:/{project route}/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:269
                                enqueue(decoded, decodeURI(pathname), pathname);
                                                 ^

URIError: URI malformed
    at decodeURI (<anonymous>)
    at visit (file:///D:/{project route}/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:269:22)

Node.js v18.13.0
[vite-plugin-sveltekit-compile] Failed with code 1
error during build:
Error: Failed with code 1
    at ChildProcess.<anonymous> (file:///D:/{project route}/node_modules/@sveltejs/kit/src/utils/fork.js:68:13)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)

System Info

bash

  System:
    OS: Windows 10 10.0.22621
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-12600KF
    Memory: 22.42 GB / 31.82 GB
  Binaries:
    Node: 18.13.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.2.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 108.0.5359.125
    Edge: Spartan (44.22621.1105.0), Chromium (110.0.1587.41)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @sveltejs/adapter-auto: ^1.0.0 => 1.0.3
    @sveltejs/kit: ^1.0.0 => 1.5.5
    svelte: ^3.54.0 => 3.55.1
    vite: ^4.0.0 => 4.1.1

Severity

serious, but I can work around it

Additional Information

No response

@dummdidumm
Copy link
Member

Please provide a slimmed down version of your reproducible by deleting as much code as possible so we get a proper minimum reproducible. Right now there are many routes and it's hard to diagnose the issue that way.

@LuticaCANARD
Copy link
Author

https://stackblitz.com/edit/nodemon-tsz9ee?file=README.md

It's seems like problem of main2 router.

@LuticaCANARD
Copy link
Author

Additional:

  • when I tried delete main2 folder at my local, that isn't work and throw that error( but at environment of stackblitz, just delete main2 and worked)
  • But when I tried delete all of router, build was worked.

@dummdidumm
Copy link
Member

It's the <link rel="icon" href="%seltekit.assets%favicon.png" /> line in app.html that's causing issues. Seems like it's not replaced and subsequently read for traversing links, at which point it fails.

@dummdidumm dummdidumm added bug Something isn't working and removed awaiting submitter labels Feb 14, 2023
@dummdidumm dummdidumm added this to the soon milestone Feb 14, 2023
@dummdidumm dummdidumm removed the bug Something isn't working label Feb 15, 2023
@dummdidumm
Copy link
Member

dummdidumm commented Feb 15, 2023

Ok this is actually a typo. It's
<link rel="icon" href="%seltekit.assets%favicon.png" />
but it should be
<link rel="icon" href="%sveltekit.assets%favicon.png" />
(note the missing v!)

Given how hard it was to debug this, I'm wondering if error handling should be better here.

@LuticaCANARD
Copy link
Author

Thanks for find my fault and make error handling.
I guess your PR looks like enough to notices about URI error to users.

@ChristopherGantert
Copy link

After struggling with a similar error for a few days here, my issue was that I had a src tag in an element pointing to an image that didn't exist. Hope this helps someone.

@marksteven
Copy link

Had same issue. Had moved (and I might be wrong here) all images from "static" folder to inside lib use to a number of references I had read that it is better to have picures inside lib so they get a key on render. However I had also moved the favicon.png as well. Readin (above) I put it back and it worked so thanks for the clue. And yes the errors thrown did not point to anything at all as others here will note. So hope it helps the next person.

@hamza-cskn
Copy link

hamza-cskn commented May 14, 2023

Had same issue. I tried deleting folders partially and in the end I found:

it does not works

import {Client} from 'pg';

const client = new Client({
    user: "postgres", host: "127.0.0.1", database: "blogs", password: "secret", port: "5432"
});

connectToDatabase();

it works.

import {Client} from 'pg';

const client = null;

connectToDatabase();

Of course null client is not proper but I meant I can build when it is set to null.

update:
chat gpt told me that change code as:

import pkg from 'pg';
const { Client } = pkg;

it works completely.

I hope it helps the next person.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants