skip to Main Content

I am in the process of creating a new react project with vite and whenever I run "npm i" inside the project the node modules and package lock are not created. I have vite and node installed and updated globally. I am on a windows machine and when I also "npm run dev" I get this error:

failed to load config from C:projectsreact+djangovite.config.js
error when starting dev server:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'vite' imported from C:projectsreact+djangovite.config.js.timestamp-1721061064614-497e48aeab21b.mjs
at packageResolve (node:internal/modules/esm/resolve:853:9)
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)

Thank you for assistance

All videos and googling suggest maybe a permissions issue or windows blocking but since im at the root directory I thought this should not be an issue.

Using yarn does work. I just want the npm i to work as well.

2

Answers


  1. I have a similar problem. When I run npm it won´t stop downloading. However, on my older vite projects it’s ok.

    Login or Signup to reply.
  2. please check your NPM versions. There seems to be a problem with version 22.5.0 right now. Try 22.4.1 or the LTS version.

    https://github.com/nodejs/node/issues/53902

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search