poppa / sveltekit-svg

SvelteKit plugin that makes it possible to import SVG files as Svelte components, inline SVG code or urls
MIT License
234 stars 23 forks source link

`Error: Cannot find module 'svgo'` #46

Closed jerrygreen closed 1 year ago

jerrygreen commented 1 year ago

I did yarn add --dev @poppanator/sveltekit-svg I added import svg from '@poppanator/sveltekit-svg' and used as plugin: plugins: [sveltekit(), svg()]

After that, I'm trying to run yarn dev and this error happens.

yarn dev
yarn run v1.22.4
$ vite dev
failed to load config from C:\Users\Jerry\projects\jerrygreen.github.io-src2\vite.config.ts
error when starting dev server:
Error: Cannot find module 'svgo'

Is this a dependency I should manually add, or?

poppa commented 1 year ago

Indeed, svgo is a peerDependency and those the consumer (you) need to install explicitly.

So yarn add --dev svgo will probably solve the problem.

jerrygreen commented 1 year ago

Indeed, it solved the issue. I guess you should add it to readme though (Or make it a normal dependency, not peer dependency)

poppa commented 1 year ago

I'm pretty sure Yarn told you you had an unmet peer dependency when installing the plugin.

jerrygreen commented 1 year ago

Indeed. On the second thought, if it's required to use this library for the most simplest cases, why make it peer dependency? IMO it should be normal dependency.