I’m trying to create a custom chart in a page. When trying to load a js file (in assets, I have run bench build), I get: ReferenceError: Can't find variable:require
All files were extracted within public folder of my custom app
All *.js file entries were added within build.json
Main js file was also included within hooks.py thereafter
bench build was run inside frappe-bench directories finally
Error:
From front end when all js fles are being loaded by Frappe framework, while loading it throws an error in console output that: require is not a function, file chart.js
Error Line 1: require(‘./core/core.js’)();
Chart.js is in the public folder there, and used in analytics/analytics/page/ (both pages). Essentially by hooking into the built chart.js all of the classes and functions are exposed for you to use in the rest of Frappe. It isn’t the most ‘efficient’ because you end up including it in head (every page) but it’s the simplest way so far.