Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vite - how to change code in node_modules folder to debug/find errors

Coming from Webpack I was able to change code in the node_modules folder in order to add a console.log statement or something like this to find errors. Sometimes I use external libraries incorrectly and it's easier to be able to alter lines/files in the node_modules folder to find out what my mistakes are.

With Vite, this is not possible. I can change whatever I want in the node_modules folder by my browser still uses the original libraries code. Is there a way that allows me to change files so Vite will recognize the changes and use my new files?

Note: it's not about pull requests or permanent changes, it's only about an console.log(typeof X) and stuff like that for a single use.

Bascially the same question as this one Changing code in node_modules does not work in hot reload regardless of the bundler

like image 779
Robin Schambach Avatar asked Nov 26 '25 21:11

Robin Schambach


1 Answers

Restart Vite dev server with the --force flag to re-bundle the deps. This has the same effect as manually deleting the node_modules/.vite directory.

See File System Cache in Dependency Pre-Bundling for more information.

like image 66
Aroldo Avatar answered Nov 28 '25 09:11

Aroldo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!