How to import a .js module in Frappe?

Ah, I think that I may have found your issue

Your file path in the frappe.require() is supposed to include the app name so instead of:

frappe.require("/assets/js/demo.js")

It should be:

frappe.require("/assets/**your_app**/js/demo.js")

path not found reason: js address problem

but this problem resolved after i found A new problem, js method not function, can you help me?

i think framework load not recognized this method, do you good idea?

How have you defined the function in your demo.js?

Yes, i already defined

image

Alright. Please try changing your frappe.require() as I suggested:

frappe.require('assets/operation/js/demo.js');

Frappe loads the files into directories per app. As an example, my app is called eskill_custom and I have a file in my public/js directory called common.js so if you were to import my file, it would be

frappe.require('/assets/eskill_custom/js/common.js');

where ?
please write directory address