vite-pwa / sveltekit

Zero-config PWA Plugin for SvelteKit
https://vite-pwa-org.netlify.app/frameworks/sveltekit
MIT License
324 stars 15 forks source link

Failed to load config v0.2.1 #46

Open nicodes opened 1 year ago

nicodes commented 1 year ago

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.
rbozan commented 1 year ago

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.

j-tai commented 1 year ago

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

Workaround: yarn add -D vite-plugin-pwa

nicodes commented 1 year ago

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