I am facing an error in react vite project.
snippet from package.json
"react": "^18.2.0",
"vite": "^5.0.0",
"vite-plugin-svgr": "^4.2.0",
The error is :
D:ReactACLAcl28node_modulesrollupdistnative.js:64
throw new Error(
^Error: Cannot find module @rollup/rollup-win32-x64-msvc. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828).
Please trynpm i
again after removing both package-lock.json and node_modules directory.
at requireWithFriendlyError (D:ReactACLAcl28node_modulesrollupdistnative.js:64:9)
at Object. (D:ReactACLAcl28node_modulesrollupdistnative.js:73:48)
2 lines matching cause stack trace …
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at cjsLoader (node:internal/modules/esm/translators:345:17)
at ModuleWrap. (node:internal/modules/esm/translators:294:7)
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24) {
[cause]: Error: The specified module could not be found.
?D:ReactACLAcl28node_modules@rolluprollup-win32-x64-msvcrollup.win32-x64-msvc.node
at Module._extensions..node (node:internal/modules/cjs/loader:1473:18)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at requireWithFriendlyError (D:ReactACLAcl28node_modulesrollupdistnative.js:62:10)
at Object. (D:ReactACLAcl28node_modulesrollupdistnative.js:73:48)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32) {
code: ‘ERR_DLOPEN_FAILED’
}
}Node.js v20.10.0
========
vite.config.js
import { defineConfig } from "vite";
import reactRefresh from '@vitejs/plugin-react';
import svgrPlugin from 'vite-plugin-svgr';
export default defineConfig({
build: {
outDir: 'build',
},
plugins: [
reactRefresh(),
svgrPlugin({
svgrOptions: {
icon: true,
},
}),
],
})
Please help in resolving the problem
The project is working fine in another system which has windows 11 as I my system has. Even if I copied whole working project including node-modules folder from another system into my system , the problem persists.
The node version is 20 in my system. Another system has node version 16.16
I am expecting to run my react-vite project properly.
2
Answers
I’m facing the same problem since yesterday… I solved it by downloading the most recent Visual C++ Redistributable. I saw a lot of guys in another forum that also got it.
You can download it here:
https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170
you can try this to solve this issue.
These steps worked for me :
1- Install Microsoft C++ Redistributable 2015
2- Remove package-lock.json
3- Delete node modules folder
4- Restart the machine
5- Run "npm install"
6- Run "npm run dev" if you’re using vite