skip to Main Content

Currently i’m running node -v v22.0.0
Here I’m creating a new React Js porject. but when initiating the project with vite technology, it errors like this in the terminal.

npm create vite@latest
node:internal/modules/cjs/loader:1205
  throw err;
  ^

Error: Cannot find module 'C:UsersrvdasAppDataRoamingnpmnode_modulesnpmbinnpm-cli.js'       
    at Module._resolveFilename (node:internal/modules/cjs/loader:1202:15)
    at Module._load (node:internal/modules/cjs/loader:1027:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:187:14)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v22.0.0

Also, when I try to create app using

npx create-react-app projectName

It also errors like above.

I tried clearning cache

npm cache clean --force

Didn’t work.

2

Answers


  1. Try the fix below. Was originally posted here.

    You have to copy C:Program Filesnodejsnode_modulesnpm to %AppData%Roamingnpmnode_modules temporarily.

    I think this issue only occurs on:

    • Fresh installation of Node v22
    • Upgraded to Node v22 but never installed npm globally (npm i -g npm) before

    The new npm script seems to only check global installation by default and will not use the version bundled in the Node installation directory.

    Login or Signup to reply.
  2. Node.js 22.1.0 has been released and npm create vite@latest (and other commands) now work properly on Windows with this new version:

    C:Development> npm create vite@latest
    
    > npx
    > create-vite
    
    √ Project name: ... vite-node22
    √ Select a framework: » React
    √ Select a variant: » TypeScript + SWC
    
    Scaffolding project in C:Developmentvite-node22...
    
    Done. Now run:
    
      cd vite-node22
      npm install
      npm run dev
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search