0

whenever i run this command: npm run dev, I get the following error. this is a sveltekit and vite (which i'm very new to) project.

> my-app@0.0.1 dev
> vite dev

failed to load config from /home/believe/Documents/my-app/vite.config.js
error when starting dev server:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@sveltejs/kit' imported from /home/believe/Documents/my-app/vite.config.js.timestamp-1659118538332.mjs
    at new NodeError (node:internal/errors:363:5)
    at packageResolve (node:internal/modules/esm/resolve:698:9)
    at moduleResolve (node:internal/modules/esm/resolve:739:18)
    at Loader.defaultResolve [as _resolve] (node:internal/modules/esm/resolve:853:11)
    at Loader.resolve (node:internal/modules/esm/loader:89:40)
    at Loader.getModuleJob (node:internal/modules/esm/loader:242:28)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:73:40)
    at link (node:internal/modules/esm/module_job:72:36)
m00nsh1n3
  • 11
  • 3

1 Answers1

0

IMHO, using / switching-to the latest version of node should ideally resolve this issue. I had faced this error, and switching to the latest version of node is what worked for me.

I have found that installing the nvm (node version manager) cli package is one of the best and handy ways to address and handle such situations. This is because, it will let you install and manage multiple versions of node, so that you can switch node versions, between projects, as needed per relevant dependencies.

For eg., in this case, I would just say nvm use latest in the project cli, and nvm will switch to the latest node version (if/where installed ==> node v18.7.0 w/ npm 8.15.00 as of now, for me, for eg. ).

At that, nvm ls lists all the installed node versions on that system/ environment, and points to the one in use at the moment. Very handy!

More info on nvm here: http://nvm.sh/

[* Since you have not mentioned the OS/ENV and Terminal etc., I can not unfortunately (at this time) share specific install instructions, and am hence pointing to the nvm git. Hope you understand. :) ]

Hope this helps; have a nice day! :)