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

Error during build: Cannot find package 'kolorist' #39

Open
udos86 opened this issue Apr 4, 2023 · 5 comments
Open

Error during build: Cannot find package 'kolorist' #39

udos86 opened this issue Apr 4, 2023 · 5 comments

Comments

@udos86
Copy link

udos86 commented Apr 4, 2023

Building a SvelteKit application with latest @vite-pwa/sveltekit fails out of the box with the following error:

error during build:
Error [PLUGIN_ERROR]: Cannot find package 'kolorist' imported from C:\xx\xx\sveltekit-sample\node_modules\@vite-pwa\sveltekit\dist\chunks\log.mjs
    at new NodeError (node:internal/errors:399:5)
    at packageResolve (node:internal/modules/esm/resolve:889:9)
    at moduleResolve (node:internal/modules/esm/resolve:938:20)
    at defaultResolve (node:internal/modules/esm/resolve:1153:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
    at link (node:internal/modules/esm/module_job:76:36)

My package versions:

"@sveltejs/kit": "1.15.0"
"@vite-pwa/sveltekit": "2.0.1"
"vite-pwa-plugin": "0.14.7"

After installing kolorist manually everything works fine.

So in order to fix this, kolorist should be added to dependencies and removed from devDependencies in package.json of @vite-pwa/sveltekit.

My service worker under src/service-worker.ts:

import { precacheAndRoute } from 'workbox-precaching';

declare const self: ServiceWorkerGlobalScope;

precacheAndRoute(self.__WB_MANIFEST);

My Vite config:

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

/** @type {import('vite').UserConfig} */
const config = {
	plugins: [
		sveltekit(),
		SvelteKitPWA({
			strategies: 'injectManifest'
		})
	],
	test: {
		include: ['src/**/*.{test,spec}.{js,ts}']
	},
	// see https://vite-pwa-org.netlify.app/frameworks/sveltekit.html#generate-custom-service-worker
	define: {
		'process.env.NODE_ENV': process.env.NODE_ENV === 'production'
			? '"production"'
			: '"development"'
	}
};

export default config;
@userquin
Copy link
Member

userquin commented Apr 4, 2023

@udos86 thx, I need to review all dependencies

@haleksandre
Copy link

I think this happens because kolorist is in your devDependencies & is listed as an external but you import it here

import('./log').then(m => m.logWorkboxResult),
to log info to the console during vite build process.

You should probably remove kolorist from the external here?

'kolorist',

@m1rm
Copy link

m1rm commented Apr 26, 2023

might be nice to know:
I ran into this issue and setting babel: false, in the svelte.config.js fixed my failing prod build and the build results were as expected afterwards

@madfrag
Copy link

madfrag commented Aug 31, 2023

any news on this one? :)

@rikimbili
Copy link

Any updates on this issue? We also encountered it.

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

No branches or pull requests

6 participants