I wanted to try out SvelteKit on MacOs 11.5.2. Using node v16.13.1, npm 8.1.2.
I have installed the SvelteKit as per original guidance:
npm init svelte@next my-app
cd my-app
npm install
npm run dev -- --open
Then, when localhost:3000 opens, I get this error:
**Error: request.query has been replaced by request.url.searchParams**
at Object.get (file:///Web/Svelte_30-12-21/my-app/node_modules/@sveltejs/kit/dist/ssr.js:1753:12)
at Object.handle (/Web/Svelte_30-12-21/my-app/src/hooks.ts:10:30)
at respond (file:///Web/Svelte_30-12-21/my-app/node_modules/@sveltejs/kit/dist/ssr.js:1764:30)
at svelteKitMiddleware (file:///Web/Svelte_30-12-21/my-app/node_modules/@sveltejs/kit/dist/chunks/index.js:4577:28)
What could be the problem?
I ran into the same problem. In src/hooks.js
replace
const method = request.query.get('_method');
with
const method = request.method;
If you are using npm init svelte@next my-app
and using the demo app, you are also going to run into a problem in Header.svelte
.
replace
<li class:active={$page.path === '/'}><a sveltekit:prefetch href="/">Home</a></li>
<li class:active={$page.path === '/about'}><a sveltekit:prefetch href="/about">About</a></li>
<li class:active={$page.path === '/todos'}><a sveltekit:prefetch href="/todos">Todos</a></li>
with
<ul>
<li class:active={$page.url.pathname === '/'}><a sveltekit:prefetch href="/">Home</a></li>
<li class:active={$page.url.pathname === '/about'}>
<a sveltekit:prefetch href="/about">About</a>
</li>
<li class:active={$page.url.pathname === '/todos'}>
<a sveltekit:prefetch href="/todos">Todos</a>
</li>
</ul>
The issue has been introduced in a commit made earlier today and reported. It has been fixed already, run npm update
or delete your node_modules
directory and reinstall.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With