I created a new React project using Vite react but after running npm install
and npm run dev
, I get the error below:
node:internal/modules/cjs/loader:1327
return process.dlopen(module, path.toNamespacedPath(filename)); ^
Error: The specified module could not be found.
\?D:OstadMERNStudentvite-projectnode_modules@rolluprollup-win32-ia32-msvcrollup.win32-ia32-msvc.node at
Module._extensions..node (node:internal/modules/cjs/loader:1327:18)
at Module.load (node:internal/modules/cjs/loader:1091:32) at
Module._load (node:internal/modules/cjs/loader:938:12) at
Module.require (node:internal/modules/cjs/loader:1115:19)at
require (node:internal/modules/helpers:130:18) at Object.<anonymous> (D:OstadMERNStudentvite-projectnode_modulesrollupdistnative.js:60:48) at Module._compile
(node:internal/modules/cjs/loader:1241:14) at Module._extensions..js (node:internal/modules/cjs/loader:1295:10) at Module.load (node:internal/modules/cjs/loader:1091:32) at Module._load
(node:internal/modules/cjs/loader:938:12) { code: 'ERR_DLOPEN_FAILED' }
Node.js v20.9.0
I previously created another React project without using Vite and everything worked fine. So, I know the issue is setting it up with Vite.
What could be the problem please?
2
Answers
try removing the node_modules folder and the package-lock.json file, after that, install the dependencies again npm install, make sure there is the dev command in the package.json scripts and run npm run dev again, this should help you
I updated my Node version by downloading it from the official site: https://nodejs.org/en/download then I tried npm run dev and it worked just fine!