question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error with SvelteKit

See original GitHub issue

Describe the bug

On Windows:

  1. Did pnpm init svelte@next
  2. Followed the steps in this repo with import "virtual:windi.css" inside src/$layout.svelte
  3. pnpm run dev gives the error

Minimal Reproductions

repository

Versions

  • vite-plugin-windicss: 0.8.3
  • vite: 2.1.0
  • framework(vue/react/svelte/etc): sveltejs/kit 1.0.0-next.49

Additonal Context On pnpm run dev:

> Executing task: pnpm run dev <


> windinew@0.0.1 dev C:\Users\HP\Desktop\windinew
> svelte-kit dev

failed to load config from C:\Users\HP\Desktop\windinew\vite.config.js
> WindiCSS is not a function
TypeError: WindiCSS is not a function
    at file:///C:/Users/HP/Desktop/windinew/vite.config.js?t=1615900612482:14:3
    at ModuleJob.run (node:internal/modules/esm/module_job:154:23)
    at async Loader.import (node:internal/modules/esm/loader:166:24)
    at async loadConfigFromFile (C:\Users\HP\Desktop\windinew\node_modules\.pnpm\vite@2.1.0\node_modules\vite\dist\node\chunks\dep-6f1d3d8c.js:46129:31)
    at async resolveConfig (C:\Users\HP\Desktop\windinew\node_modules\.pnpm\vite@2.1.0\node_modules\vite\dist\node\chunks\dep-6f1d3d8c.js:45783:28)  
    at async Object.createServer (C:\Users\HP\Desktop\windinew\node_modules\.pnpm\vite@2.1.0\node_modules\vite\dist\node\chunks\dep-6f1d3d8c.js:68984:20)
    at async Watcher.init_server (file:///C:/Users/HP/Desktop/windinew/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.49_d563d1e4217ff8882402c11be2b46d5a/node_modules/@sveltejs/kit/dist/chunks/index.js:3225:24)
    at async Watcher.init (file:///C:/Users/HP/Desktop/windinew/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.49_d563d1e4217ff8882402c11be2b46d5a/node_modules/@sveltejs/kit/dist/chunks/index.js:3195:3)
    at async file:///C:/Users/HP/Desktop/windinew/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.49_d563d1e4217ff8882402c11be2b46d5a/node_modules/@sveltejs/kit/dist/cli.js:474:20
file:///C:/Users/HP/Desktop/windinew/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.49_d563d1e4217ff8882402c11be2b46d5a/node_modules/@sveltejs/kit/dist/chunks/index.js:3488
                this.viteDevServer.close();
                                   ^

TypeError: Cannot read property 'close' of undefined
    at Watcher.close (file:///C:/Users/HP/Desktop/windinew/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.49_d563d1e4217ff8882402c11be2b46d5a/node_modules/@sveltejs/kit/dist/chunks/index.js:3488:22)
    at process.<anonymous> (file:///C:/Users/HP/Desktop/windinew/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.49_d563d1e4217ff8882402c11be2b46d5a/node_modules/@sveltejs/kit/dist/chunks/index.js:3185:9)
    at process.emit (node:events:379:20)
    at process.EventEmitter.emit (node:domain:470:12)
    at process.exit (node:internal/process/per_thread:178:15)
    at handle_error (file:///C:/Users/HP/Desktop/windinew/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.49_d563d1e4217ff8882402c11be2b46d5a/node_modules/@sveltejs/kit/dist/cli.js:451:10)
    at file:///C:/Users/HP/Desktop/windinew/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.49_d563d1e4217ff8882402c11be2b46d5a/node_modules/@sveltejs/kit/dist/cli.js:487:4
 ERROR  Command failed with exit code 1.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
JustinVoitelcommented, Mar 18, 2021

@NoelJacob This worked for me without removing type: "module" :

import WindiCSS from 'vite-plugin-windicss'

export default {
  plugins: [WindiCSS.default()],
  // other kit stuff ...
}
2reactions
ohmreecommented, Aug 3, 2021

I’ve also ran into this with "type": "module" (I load my vite config on the server and one of my server deps is esm-only so I have to use "type": "module" on both the client and the server).

A fix that seems to work perfectly is going into the plugin’s package.json and adding this:

"exports": {
  ".": {
    "import": "./dist/index.mjs",
    "require": "./dist/index.js"
  }
}

Which seems odd and redundant but hey, my editor doesn’t complain anymore and it seems to work fine in the vite dev server. So is there a possibility of this fix getting added? Is there any drawback to adding it? Should I open a PR?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Errors • Docs • SvelteKit
Errors are an inevitable fact of software development. SvelteKit handles errors differently depending on where they occur, what kind of errors they are, ......
Read more >
replace `%sveltekit.message%` with `%sveltekit.error ... - GitHub
It would make sense if we respected the App.PageError shape in src/error.html . Describe the proposed solution. Change %sveltekit.message% to % ...
Read more >
I am facing error while runing sveltekit app (Not found:/)
Pages have been renamed from index.svelte to +page.svelte . When you rename your routes they should be detected without a custom entry file...
Read more >
Using `throw error` on a server endpoint. How to get it ... - Reddit
On a server-side only endpoint, I use `throw error`, error being the export from sveltekit. How do I pass that to the `+error.svelte`...
Read more >
Error loading module in Sveltekit - Netlify Support Forums
Hello there, I'm working on a SvelteKit website and deploying it to Netlify. I'm having some issues with a particular error.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found