Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

228
Views
Failed to resolve module specifier "three" - Working Three/Wordpress Integration Suddenly Failed

I manage a WordPress website which uses a Three.js animation on the homepage. I built this site months ago and everything had been working perfectly fine - I even showed it to someone a week ago and nothing was amiss. Yesterday, I check the site and find that Three is not loading, and that I have this in the console:

Uncaught TypeError: Failed to resolve module specifier "three". Relative references must start with either "/", "./", or "../".

I don't have a line or even file to reference, the error is logged coming from the first line of the root domain. I want to emphasize that I had changed absolutely nothing about the set-up. I hadn't even updated to WP 5.9 yet. This is how I had originally set things up. Sorry if it's not best practices, but I want to emphasize that it did in fact work fine. Enqueuing animation javascript file and defining its type as "module":

function my_custom_scripts() {
    wp_enqueue_script( 'gsap', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.7.0/gsap.min.js', array( 'jquery' ), '', true);
    wp_enqueue_script( 'scrolltrigger', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.7.0/ScrollTrigger.min.js', array( 'gsap' ), '', true);
    wp_enqueue_script( 'custom-animations', get_stylesheet_directory_uri() . '/js/animations.js', array( 'gsap' ),'',true );
    
}
add_action( 'wp_enqueue_scripts', 'my_custom_scripts', 15);

add_filter('script_loader_tag','add_type_to_script', 10, 3);
function add_type_to_script($tag, $handle, $source){
    if ('custom-animations' === $handle) {
        $tag = '<script type="module" src="'. $source .'"></script>';
    } 
    return $tag;
}

First lines of "animations.js":

import * as THREE from 'https://cdn.skypack.dev/three@0.137.5/build/three.module.js';
import { GLTFLoader } from "https://threejs.org/examples/jsm/loaders/GLTFLoader.js";
import { DRACOLoader } from 'https://threejs.org/examples/jsm/loaders/DRACOLoader.js';

If there is other relevant code to this problem, please let me know, but I've been pouring over this and tried A) downloading the module file and putting it on my own server and providing a relative path, the same console issue appears (though it did complain with a 404 if the link was invalid, suggesting it did follow it). B) downloading the three.min.js file and loading it before this one, removing the module call entirely and I still get the same console error (even though it's not even being imported as a module). This site has been hosted on Cloudflare, so I did disable that first. Clearing the cache changed nothing, and I have confirmed at every step that I have not been loading a cached version. In the Network tab of Chrome dev tools, the module/file gets loaded into the cache just fine. Somewhere along the way, some file (I wish the console would specify, maybe that is indicative of the problem) fails to attach "Three" as a module and I have no idea why. Any help would be massively appreciated!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I had exact same problem. I uploaded my project on Github a month ago (https://kramzin.github.io/threejs-task/) and since then didn't change a one symbol, but about a week ago it started showing same strange error in console. I found following: "Since r137 using ES6 modules like GLTFLoader in the browser requires an import map. Add the following section right below you canvas."

<script type="importmap">
    {
        "imports": {
            "three": "../master/three.js-master/build/three.module.js"
        }
    }
</script>

The three.js import statement in your scripts.js looks like so then:

import * as THREE from 'three'

https://github.com/Kramzin/threejs-task - Here you can see updated and previous code, after these changes everything started working

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!