WordPress Import Node-modules with javascript problem
-
Hi, I’m having trouble with some javascript and CROSS policy.
I need to import modules in javascript to extend some functionalities of Tone.js, a javascript library I want to use.
I have one “import.js” file, with the following code:
import {Context} from './node_modules/tone';
The folder “node_modules” is inside my js folder with the import.js file too.
I used “wp_enqueue_script” in functions.php to load the import.js file, and I used a filter to add thetype="module"to the script tag.
But, on loading, I got this error in console: “Access to script has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.”What have I to do here to correctly import it?
The topic ‘WordPress Import Node-modules with javascript problem’ is closed to new replies.