dependency error when using pnpm
raghed-kahil opened this issue · comments
Describe the bug
when i run pnpm dev
this error appears
failed to load config from C:\path\to\project\vite.config.ts
error when starting dev server:
Error: Cannot find package 'C:\path\to\project\node_modules\.pnpm\@sveltejs+kit@2.5.18_@sveltejs+vite-plugin-svelte@3.1.1_svelte@4.2.18_vite@5.3.3_@types+node@_vf6eowwt6pjwdxo6ynlxfah3wi\node_modules\set-cookie-parser\package.json' imported from C:\path\to\project\node_modules\.pnpm\@sveltejs+kit@2.5.18_@sveltejs+vite-plugin-svelte@3.1.1_svelte@4.2.18_vite@5.3.3_@types+node@_vf6eowwt6pjwdxo6ynlxfah3wi\node_modules\@sveltejs\kit\src\exports\node\index.js
Did you mean to import set-cookie-parser@2.6.0/node_modules/set-cookie-parser/lib/set-cookie.js?
at legacyMainResolve (node:internal/modules/esm/resolve:214:26)
at packageResolve (node:internal/modules/esm/resolve:840:14)
at moduleResolve (node:internal/modules/esm/resolve:910:20)
at defaultResolve (node:internal/modules/esm/resolve:1130:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
at link (node:internal/modules/esm/module_job:84:36)
ELIFECYCLE Command failed with exit code 1.
i am using adapter/node
working fine with npm
it's not vite related
it working with docker
i tried setting CI=true
i tried commenting this line in svelte-kit file and error disappeared but it obvious that it will break some functionality
// file: @sveltejs/kit/src/exports/node/index.js
import * as set_cookie_parser from 'set-cookie-parser';
Reproduction
pnpm create svelte@latest
pnpm i
pnpm dev
Logs
failed to load config from C:\path\to\project\vite.config.ts
error when starting dev server:
Error: Cannot find package 'C:\path\to\project\node_modules\.pnpm\@sveltejs+kit@2.5.18_@sveltejs+vite-plugin-svelte@3.1.1_svelte@4.2.18_vite@5.3.3_@types+node@_vf6eowwt6pjwdxo6ynlxfah3wi\node_modules\set-cookie-parser\package.json' imported from C:\path\to\project\node_modules\.pnpm\@sveltejs+kit@2.5.18_@sveltejs+vite-plugin-svelte@3.1.1_svelte@4.2.18_vite@5.3.3_@types+node@_vf6eowwt6pjwdxo6ynlxfah3wi\node_modules\@sveltejs\kit\src\exports\node\index.js
Did you mean to import set-cookie-parser@2.6.0/node_modules/set-cookie-parser/lib/set-cookie.js?
at legacyMainResolve (node:internal/modules/esm/resolve:214:26)
at packageResolve (node:internal/modules/esm/resolve:840:14)
at moduleResolve (node:internal/modules/esm/resolve:910:20)
at defaultResolve (node:internal/modules/esm/resolve:1130:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
at link (node:internal/modules/esm/module_job:84:36)
ELIFECYCLE Command failed with exit code 1.
System Info
System:
OS: Windows 11 10.0.22000
CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Memory: 4.39 GB / 11.89 GB
Binaries:
Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
npm: 10.8.1 - C:\Program Files\nodejs\npm.CMD
pnpm: 9.5.0 - C:\Program Files\nodejs\pnpm.CMD
Browsers:
Edge: Spartan (44.22000.2600.0), Chromium (126.0.2592.81)
Internet Explorer: 11.0.22000.2600
npmPackages:
@sveltejs/adapter-auto: ^3.2.2 => 3.2.2
@sveltejs/adapter-node: ^5.2.0 => 5.2.0
@sveltejs/kit: ^2.5.18 => 2.5.18
@sveltejs/vite-plugin-svelte: ^3.1.1 => 3.1.1
svelte: ^4.2.18 => 4.2.18
vite: ^5.3.3 => 5.3.3
Severity
serious, but I can work around it
Additional Information
No response
after a lot of investigation i discovered that this package was causing problem @types/jsonwebtoken
i don't know why but after removing it and deleteing node_modules then reinstalling problem solved
after more investigation i discovered that package @types/node
is the main reason for error and when installing @types/jsonwebtoken
it auto installs @types/node
even if you remove it using pnpm rm @types/node
it remains in project and in lock file until you delete both lockfile and node_modules
looklike it's pnpm related bug
I'm going to go ahead and close this since I use pnpm constantly and don't see any issues with it and it sounds like you've solved your problem