I was building a React project with Vite and it was going great. I needed to add some charts and found out about the recharts package and really liked it so downloaded it into my project with the command npm i recharts
.
I get the following message:
I then ran npm audit
, npm audit fix
and npm audit fix --force
and got this:
Now when I try to start up my project with npm run dev
I get this error in the console:
Uncaught TypeError: import_events.default is not a constructor
It says it's coming from a file called Events.js but I do not have such a file in my project.
I tried running npm audit fix --force
multiple times like my terminal told me to but it did not work.
CodePudding user response:
I'm not sure what exactly happened to your project but it seems that's because security issues you can read more in here ,I think reinstalling modules and clearing cache might do what you want :
for clearing cache : npm cache clean –force
and for reinstalling modules : npm ci --force
CodePudding user response:
It's possible that running npm audit fix --force may have caused some changes to your project that are causing the errors you're seeing.
It's generally not recommended to use the --force flag with npm audit fix, as it can potentially cause problems with your project. Instead, you should try to carefully review the output of npm audit and fix any vulnerabilities manually, or use the --package-lock-only flag to update your package-lock.json file without modifying your project.
In this case, it may be best to try uninstalling the recharts package and then reinstalling it without using the --force flag. You can try running the following commands to do this:
npm uninstall recharts
npm install recharts
In some cases, deleting the node_modules folder and running npm install can help fix issues with a project. The node_modules folder contains all the dependencies for your project, and running npm install will reinstall them from the package.json file.