Reflect JS and Python changes instantaneously

Do I have to run bench build every time I make any change to a .js and bench restart for .py files (core erpnext or frappe files)? Or is there a config setting that can make the changes reflect without rebuilding?

I’m already on a development branch and I have set my site for development mode, but interestingly I see FRAPPE_ENV=production everytime I run the build command. See snip below

Also, after running ‘bench build’, the JS code in the browser debugger window doesn’t show the modified file.

I have my ERPNext on a Debian VM (no GUI) hosted on GCloud and I access the site from the browser on my local machine

changes made to js will reflect when u clear cache on browser and refresh ( ctrl+ shift + r), for python files, you can migrate your site using bench --site sitename migrate then clear cache and restart

and it is not recommended to edit core files directly, it will cause issues when you update

Thanks @neerajvkn for replying!

Let me see if I understood it correctly - so you are saying that once I run bench --site sitename migrate :-

  1. I should no longer be required to run ‘bench build’ and ‘bench restart’ everytime I make changes to .js and .py core filed.
  2. This bench migrate command had to be run only once and any subsequent changes to .js and .py files will not be followed by a bench migrate. Is that so?
  3. For reflecting the .js changes, only clearing the browser cache should work and no need for bench build. That’s what I was expecting since I started making changes in the files, but it was not working, maybe because I didn’t do bench migrate

While you (or anyone else) replies back to my questions, I’m gonna try out what you have suggested and would be back with my findings.

Yup, I totally know that. I have created my own git development branch for the frappe and erpnext repositories. I’m trying to setup some debugging process for which I’m playing around with the core files. It’s going to help me understand better the flow of information and the calculations/logic that goes behind the scenes on some complex screens (like the sales tax calculation logic).

  1. for js files, you can just refresh your browser (clear cache and refresh), for py files, what i do normally is bench --site [sitename] migrate, bench clear-cache, bench restart,( i only edit files of my custom apps)

but my understanding is that if you do the migrate command, it pulls latest files from official frappe repo and replaces any core files that does not match the official versions, so any changes made to core files, js or py, will be reverted. (i maybe wrong)

so you are better off with bench build and bench restart like you are currently doing if you are editing ‘core’ files.

  1. bench migrate, clear cache and restart have to be run everytime any changes is done to py files, this bench migrate compiles python files and when bench restart is done, this changes are put into effect.

  2. thats a weired behvaiour, tried any other browsers?

Hi @neerajvkn, I am facing same issue with python files. Not able to see python file changes on local. I followed your step by bench --site current_sitename migrate , bench clear-cache, bench restart. Nothing worked for me.
Please let me know, if anything you know about it

Hello @mkashif14 were you able to find a solution to this because i’m experiencing the same thing.
Thank you in advance

It’s actually depends on whether you’re using Production or Development environment.

Production Environment:
Client Script: when you make changes in doctype js file then you don’t need to run any bench migrate or bench clear-cache command, but if you’re making changes in the files which’re linked in build.json file(inside public dir) then you’ve to run bench build command to build the new assets and reload the browser to see the changes(reload it by clicking on reload button under the navbar profile menu as it’s clear the cache automatically).
Python: You’ve to execute sudo supervisorctl restart all command to reflect the changes.

Client Side: If you make changes in doctype js then you don’t to build the assets. Even if you’re making changes in public folder js files you don’t need to execute the bench build command because bench watch command(It’s a sub command of bench start command) automatically re-build the assets after you save the file.
Python: No need to call run any command as bench watch command reload the py-cache files automatically. If it doesn’t then you need to reload the browser to see the changes.

For development you have to add development_mode: 1 in site_config.json file.(don’t set it true or false because frappe framework strictly compare the value with 1)

Sometime due to browser issue(especially on website) doesn’t clear the cache. To fix this issue you need to change__version__ value in module file.
For instance:

__version__ = 0.1(module file)
<script src="/assets/js/test.js?ver=0.1"></script>

and also set no_cache=True(in www folder py files) to reload the website-context automatically when you reload the website if you’re using context based javascript.


Thank you very much for the reply.