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

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

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.

Dep Pre-Bundling
According to archive.org:vitejs.dev/guide/dep-pre-bundling.html it's not called "caching" but rather "dep pre-bundling" - y'know, because we wouldn't want the average Joe's search terms to work now would we? 😉
Delete Vite Cache
rm -rf ./node_modules/.vite
Reload Dev without Vite Cache
rm -rf node_modules/.vite; npm run dev
Monkey Patch Away
I was pulling my hair out trying to debug a dependency that needed a PR and doing dumb stuff like republishing vite-shim-foobar because I couldn't find the cache, but... I found it. So now I can monkey patch to debug things too!

Related

Heroku install specific Tex Buildpacks

My latex file uses many packages which are imported with \usepackage.
On my local computer the packages are being correctly interpreted and the tex-file is compiled. When deployed on Heroku it stops running and I get plenty of error messages that some packages are missing.
For example: cmap.sty, etoolbox.sty, pdfx.sty, and many more. I started to add the files to my working directory. There are so many of them and it seems there should be an easier solution.
At the moment I am using a tex-live buildpack. I added the link to my Heroku build-packs, it does the job for simple latex files without any special packages required.
I created the file texlive.packages and added it to my repo. The file contains:
collection-bibtexextra
collection-fontsextra
collection-langgerman
collection-xetex
The deployment to Heroku is rejected because the slugfile excites more than 1.2G and only 500Mb are allowed.
These collections are quite big, and I can install max 2 of them.
I know that these collections containing a lot of packages I don't need.
How can I install only the required packages for my use case? Or how can I exclude some of them.

Changes in the vue file not applying in the browser

I am working in project having technology(laravel + vuejs).In that there is a form created in vue file and i want to add a text in the vue file.So as i have seen that "when any changes is done in vue file then need to rebuild the application".And i see that there are commands for rebuild the application is npm run dev , npm run prod , npm run watch and npm run watch-poll. I have tried all this commands after saving the file through FTP but sometimes the changes is applied (Note : Not immediately but after some duration) and sometimes no changes apply in the browser.When i tried the above command by executing it then there is no such error occurs and the rebuild is done successfully.So what will be the issue can you please suggest something that i need to configure?
Below is the code of package.json,webpack.mix.js file and after that i have attached image of putty in which application rebuild is done.
Thanks in advance!
I think you are not understanding what npm run dev/prod/watch do. If you alter the .vue file in your resources folder, then have npm rebuild your assets, then ftp the vue file to your server, nothing should happen.
Depending on how you have your laravel mix file set-up, the file you need to ftp to the server is likely public/js/app.js.
You should really consider getting your local environment setup for development, there is nothing I can image worse than viewing your changes by ftp-ing files to a server.

Cmder seems to be broken after git push, how can I fix the clink.lua?

I'm working in a group using GitHub, and when I tried transferring my work to the remote repo it didn't allow me to. It says I must do git pull first, so I did. That created some conflict in my code, then I tried to do git push again and that didn't work either.
So I switched to a new branch and tried to push from there. Didn't work with a simple git push, but a similar instruction worked for me.
Since then cmder keeps showing this:
C:\laragon\bin\cmder\vendor/clink.lua:219: attempt to index local 'HEAD' (a nil value)
C:\laragon\www\pharmacie>
Which allows me only to use instructions like php artisan serve, but not Git instructions like git status...
I already tried some clink.lua code that I found on github, but didn't work.
I tried abandoning my project, so I cloned the remote repo locally.
But then it didn't clone the vendor folder or the .env file; so I added them from an other repo (so it could compile) and changed the DB name in the .env file to match my project.
Now it keeps giving an error that says the table of the project I got vendor + .env from doesn't exist. But I didn't leave that table in the .env, I changed it to my project.
Any help?
Your problem is probably due to a conflict in a file you didn't handle.
When there is a conflict, a file usually looks like this:
<<<<<<<<< HEAD
// Some code
==============
// Some other code
>>>>>>>>> branch
And you have to choose what you want to save and what you want to delete after the merge.
So I would recommend to you to check your C:\laragon\bin\cmder\vendor/clink.lua file at line 219 to see if it could contain what I just said above.
And by the way, you should add your vendor folder in your .gitignore
And for the problem with your .env file, did you run php artisan migrate ?
EDIT
And because the problem come from your vendor folder, you could resolve it by deleting your vendor folder and run composer install to reinstall your dependencies
I have been facing the same issue. I resolve the issue by updating the cmder.
As like the image above for that click on the upper right corner (Setting) on the cmder window.
1. Choose: General -> Update
2. Check the Startup checkbox for (Do automatic check on) and then
3. Click the save settings button
4. Restart the cmder.
5. It will prompt for update and allow it to update.
6. Restart cmder again and it will resolve the issue.
I repair it as follows:
clone the repository again into another folder
access the hidden .git folder and copy only the folders (hooks, info, logs ...), do not copy the files
replace the folders in the .bin folder of the newly cloned project with the old one
with this I recover the branches and the code of my project, I hope and it will be useful to someone.

Laravel - views folder getting deleted repeatedly

Using Laravel Framework 5.5.0.
The /var/app/current/storage/framework/views folder is constantly getting deleted.
Has anyone experienced this behavior or know why this would be happening?
*Also worth noting I attempted to circumvent this by setting the immutable flag on the directory but then my frontend stoped working.
Looks like the folder is getting deleted because there is no files tracked by git inside.
Try to add .gitignore to the storage/framework/views with the following content:
*
!.gitignore
Then remove all gitigore rules for views folder in root .gitignore.
You should be able to add this file to git index and commit. The problem should be fixed after next deploy.
See: How can I add an empty directory to a Git repository?

How can I set up Composer with perforce

How do I set up Perforce with Composer so that files such as the vendor folder are not writable by Perforce?
For example the composer lock file.
Three options (you can do any or all of these):
Add these files to your P4IGNORE. That will stop you from adding them.
Remove these files from your client view. That will stop you from adding them OR syncing them.
Remove these files from the protections table (this requires you to be an admin). That will stop ANYONE from adding them.

Resources