sveltekit icon indicating copy to clipboard operation
sveltekit copied to clipboard

Failed to load config v0.2.1

Open nicodes opened this issue 1 year ago • 3 comments

I'm getting an error when using this package "@vite-pwa/sveltekit": "0.2.1" with a freshly created project using "@sveltejs/kit": "^1.5.0". Can anyone please let me know if these versions are incompatible?

I have setup the basic config file following the documentation describes:

import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import { SvelteKitPWA } from '@vite-pwa/sveltekit';

export default defineConfig({
	plugins: [sveltekit(), SvelteKitPWA()]
});

Below is the run time error:

failed to load config from /Users/.../sveltekit-app/vite.config.ts
error when starting dev server:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'vite-plugin-pwa' imported from /Users/.../sveltekit-app/node_modules/@vite-pwa/sveltekit/dist/index.mjs
    at new NodeError (node:internal/errors:387:5)
    at packageResolve (node:internal/modules/esm/resolve:852:9)
    at moduleResolve (node:internal/modules/esm/resolve:901:20)
    at defaultResolve (node:internal/modules/esm/resolve:1115:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:837:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36)
error Command failed with exit code 1.

nicodes avatar Apr 28 '23 05:04 nicodes

Weirdly enough I had the same but I figured out it was because I used yarn instead of npm install in my NPM project .. Not sure if some new pkg update which yarn did not follow broke anything, but at least it works now for me.

rbozan avatar May 02 '23 06:05 rbozan

Yeah, it's caused by installing @vite-pwa/sveltekit using yarn instead of npm.

Workaround: yarn add -D vite-plugin-pwa

j-tai avatar May 05 '23 17:05 j-tai

@rbozan @j-tai I used pnpm but the docs say it's supported https://vite-pwa-org.netlify.app/frameworks/sveltekit.html

nicodes avatar Jun 10 '23 20:06 nicodes