poppa / sveltekit-svg

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

Error: Cannot find module '@rollup/pluginutils' #54

Closed sntsris closed 8 months ago

sntsris commented 8 months ago

Hi. Very nice plugin.

However, I've encountered an issue. When I configure the settings and start the application, I get the following error:

> web@0.0.1 dev
> vite dev

failed to load config from /app/vite.config.ts
error when starting dev server:
Error: Cannot find module '@rollup/pluginutils'
Require stack:
- /app/node_modules/@poppanator/sveltekit-svg/dist/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/app/node_modules/@poppanator/sveltekit-svg/dist/index.js:5:23)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at cjsLoader (node:internal/modules/esm/translators:345:17)

Here are the relevant devDependencies from my package.json:

    "devDependencies": {
        "@poppanator/sveltekit-svg": "^4.2.0",
        "@sveltejs/adapter-auto": "^3.0.0",
        "@sveltejs/adapter-cloudflare": "^3.0.1",
        "@sveltejs/kit": "^2.0.0",
        "@sveltejs/vite-plugin-svelte": "^3.0.0",
        "@types/eslint": "8.56.0",
        "@typescript-eslint/eslint-plugin": "^6.0.0",
        "@typescript-eslint/parser": "^6.0.0",
        "eslint": "^8.56.0",
        "eslint-config-prettier": "^9.1.0",
        "eslint-plugin-svelte": "^2.35.1",
        "prettier": "^3.1.1",
        "prettier-plugin-svelte": "^3.1.2",
        "svelte": "^4.2.7",
        "svelte-check": "^3.6.0",
        "sveltekit-superforms": "^1.13.1",
        "svgo": "^3.2.0",
        "tslib": "^2.4.1",
        "typescript": "^5.0.0",
        "vite": "^5.0.3",
        "wrangler": "^3.22.2",
        "zod": "^3.22.4"
    },

Do you have any suggestions on how to resolve this issue? I would greatly appreciate your help.

Thanks!

codercms commented 8 months ago

I had the same issue with SvelteKit 2, try npm install @rollup/pluginutils --save-dev , it should fix this error

jakeanq commented 8 months ago

When testing 5.0.0-svelte5.0 I encountered the same issue.

On both that version and 4.2.0 the sveltekit-svg package does not appear to list a runtime or peer dependency for @rollup/pluginutils - only a dev dependency.

I think downgrading to @poppanator/sveltekit-svg@4.1.3 (the previous version) would also be a valid workaround, it doesn't use the above package.

poppa commented 8 months ago

Sorry guys, my misstake. This should now be fixed in 4.2.1

poppa commented 8 months ago

And the experimental support for Svelte5 package should now also be updated: 5.0.0-svelte5.1

jakeanq commented 8 months ago

That fixes it for me on Svelte5, thanks!

sntsris commented 8 months ago

thanks! I have confirmed that it was fixed in Svelte 4.