What is a way to utilize Three.js without relying on Node.js, Express, or any build tools?

Objective: Start by importing the necessary modules...

Issue: When trying to import jsm files like OrbitControls.js using from 'three';, an error occurs:

[Error] TypeError: Module specifier, 'three' does not start with "/", "./", or "../". promiseReactionJob

Various suggestions have been made, from manually copying files from node_modules and adjusting the path, to waiting for browsers to support relative paths. However, I would like to find a solution to use the tool on a regular server in the meantime...

What is the recommended approach for servers that are NOT based on Node.js?

Answer №1

The official explanation states that the jsm components are categorized under "examples" for a specific purpose - users are encouraged to duplicate and modify them for their own applications, so substituting absolute paths is perfectly acceptable.

Typically, I avoid altering anything within the node_modules directory, but in this scenario, it is actually endorsed by three.js.

For further information on module resolution, you can refer to this article.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Definition of a Typescript Global.d.ts module for a function that is nested within another function

Simply put, I have a npm module that exports a function along with another function attached to it: // @mycompany/module ... const someTool = (options) => { // do some cool stuff }; someTool.canUseFeature1 = () => { return canUseSomeFeature1(); ...

Looking to transform a response from a two dimensional array into a JSON object using Angular 9

I received the following response from my NodeJS backend: Current Response: [ [ '49' ], [ '33' ], [ '60' ], [ '58' ] ] I need to convert these values into JSON Object format as shown below in Angular 9 on my front ...

A guide to swapping text in a jQuery DOM component

In order to construct HTML from a jQuery ajax response, I prefer not to nest unsightly strings in javascript and avoid using templating scripts like mustache. Instead, I decided to utilize a template HTML with display: none as shown below: <div id="mes ...

Modifying the ajax POST data for a subsequent request by utilizing .done() instead of success

I find myself in a bit of a puzzle here. I have developed several Ajax functions that trigger one another sequentially upon receiving a valid success response from the previous one. For example... (I have excluded extensive portions of the code that vali ...

Exploring the functionality of promises in JavaScript

Currently, I am using the most recent version of Angular. The code snippet I've written looks like this: $q.all({ a: $q.then(func1, failHandler), b: $q.then(func2, failHandler), c: $q.then(func3, failHandler), }).then(func4); Is it guaranteed ...

What is the best way to invoke a controller method using jQuery within a cshtml file?

I am working on a project where I need to add user information to the database by calling a function in my controller class. The user's information is entered through a form created in a .cshtml file that interacts with an external JavaScript file. Is ...

Developing a dynamic modal using Angular and embedding Google Maps within an iframe

I'm currently working on implementing a modal in my Angular application that, when opened, displays Google Maps within an iframe. The problem I'm facing is that the iframe isn't loading and I'm receiving this error in the browser conso ...

sending properties into a vue2 component

I have a simple Vue component that I am trying to pass information into using props. The HTML code for this looks like: <myapp v-bind:source-key="some_key" v-bind:destination-key="some_other_key"></myapp> Here is the compon ...

Storing data in a TypeBuffer and then retrieving it from a file can lead to surprising outcomes

Upon executing the following code: var list = new Uint32Array(16); for (var i=0; i<16; ++i) list[i] = i; fs.writeFileSync("list", new Uint8Array(list).buffer); console.log([].slice.call(new Uint32Array(fs.readFileSync("list")))); We anticipate the out ...

Is there a method to instruct crawlers to overlook specific sections of a document?

I understand that there are various methods to control the access of crawlers/spiders to documents such as robots.txt, meta tags, link attributes, etc. However, in my particular case, I am looking to exclude only a specific portion of a document. This por ...

Adding class name to alternate posts in Next.js

I am currently working on a project with nextjs where I am attempting to fetch a list of images. I want to dynamically add a class based on a condition. Specifically, for every even post, I want to add the class name "mt10". Below is the code snippet I am ...

How to address critical vulnerabilities found in a Vue.js project that relies on the 'vue-svg-loader' dependency, specifically impacting 'nth-check', 'css-select', and 'svgo'?

Attempting to launch a Vue version 2 project, encountered the following error: # npm audit report nth-check <2.0.1 Severity: high Inefficient Regular Expression Complexity in nth-check - https://github.com/advisories/GHSA-rp65-9cf3-cjxr fix available ...

What is the best way to interact with Redis without using any external modules?

I am curious about the communication process between the node redis wrapper and the RESP (REdis Serialization Protocol) database. Here is a simple example: const redis = function(uri) { this.client = '' // How do we establish a connection wit ...

Watching for changes to an object's value in an AngularJS service triggered by a controller from a separate module (Extended Edition)

Referring to this discussion on Stack Overflow: AngularJS trigger and watch object value change in service from controller The original question was about watching for changes in a service from a controller. I am interested in extending this concept to ...

Fetching real-time Twitter search feeds through dynamic AJAX requests

Previously, I successfully used JSON to retrieve hash tag feeds from Twitter and Facebook. However, currently the feeds are not updating dynamically, indicating a need for Ajax implementation. Unfortunately, my lack of knowledge in Ajax is hindering this ...

Scrolling causes the image to blink

I have a specific task to create an effect where an image blinks three times on scrolling (like lights turning on and off consecutively with a 1-second delay), and then stays on until the user scrolls beyond 3600px. To achieve this, I have added an event ...

Delete the browsing cache in Internet Explorer from an external source

Currently, I am working on developing an ASP.NET application using Visual Studio. However, a persistent issue I am facing is that every time I launch the application, Internet Explorer caches certain CSS and JS files. This forces me to manually clear the c ...

Occasionally, an AJAX request may be terminated when making multiple calls to the API

Within an application environment, a URL is being called via AJAX four times. Interestingly, on a specific page, the AJAX request gets canceled when attempting the fourth invocation. The fourth request shows "Provisional headers are shown" in its request ...

Curious about the power of jQuery methods?

I've been coming across codes similar to this: $(document.documentElement).keyup( function(event) { var slides = $('#slides .pagination li'), current = slides.filter('.current'); switch( event.keyCode ) { ...

Tips for retrieving the value of a corresponding data attribute by the text within a div using jQuery in JavaScript

I have several divs with different names and values assigned to the data attribute data-category Now, I am in need of retrieving the value of data-category based on specific text present inside the div. <div class='ext-category' data-categor ...