pat66
May 9, 2025, 7:06pm
1
Hi everyone
I buy this course and I begin on webGL
Creating a simple portfolio website with WebGL and Barba.js
I create this page and I put this code I get on the github
but nothing append on the screen I get this message on the console
“Uncaught SyntaxError: Cannot use import statement outside a module”
can I have some idea about how to fix this ?
thanks by advance.
<script src="app.js">
to
<script type="module" src="app.js">
or
<script type="module" src="./app.js">
1 Like
pat66
May 9, 2025, 7:12pm
3
Chaser_Code:
type=“module”
I thanks for your message now I have this
Need for local server like xampp, open server or load to github.
pat66
May 9, 2025, 8:56pm
5
Thanks for your messsage I install nodejs now but I get this
now no error but nothing appear on the page I suppose to have a cube
send project files here for testing
pat66
May 9, 2025, 9:05pm
7
Chaser_Code:
ok
app.js (830 Bytes)
index.html (423 Bytes)
style.css (197 Bytes)
Change type="modules"
to type="module"
Into app.js
set path for three.js file import * as THREE from 'three';
my path is import * as THREE from './three_172.js';
Download: www.zip (260.9 KB)
1 Like
pat66
May 9, 2025, 9:51pm
9
thanks for the message I will try tomorow
Run it on server, nor like this
Delete this line, because three_172.js
already have path to three.core.js
:
Another solution is leave path in app.js: import * as THREE from 'three';
and define path at index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<div id="container"></div>
<script type="importmap">
{
"imports":{
"three":"./three_172.js",
"three/addons/":"./jsm/"
}
}
</script>
<script type="module" src="./app.js"></script>
</body>
</html>
jrlazz
May 12, 2025, 3:37am
13
Hi @pat66 …
I have been working with Three.js pages in a different way for a long time.
If you want to follow my advice:
Create a directory named 3D in C:
Place the zipped contents in myserver.zip in the 3D directory.
Run quick.bat and open a web browser by typing 127.0.0.1 and pressing ENTER.
Click on the web line and click on hello.html
Here goes the zip file…
myserver.zip (3.2 MB)
You will get these twuo screens…
pat66
May 13, 2025, 5:51pm
14
Hi
thanks for your message I try now I have this message
this is a capture on the course
don’t understand this message error
You probably need a:
<div id="container"> </div>
inside the <body>
of your html.
1 Like
pat66
May 13, 2025, 7:39pm
17
I’m using a 32 bits operating system is it a problem to run webgl website
jrlazz
May 13, 2025, 8:46pm
18
Hi @pat66 …
Searching in Google:
No, it’s not inherently problematic to run a WebGL website with Three.js on a 32-bit machine. WebGL and Three.js are designed to be platform-independent and can run on a wide variety of hardware, including 32-bit systems
pat66
May 13, 2025, 8:50pm
19
I ask because I don t understand why I have so many problem with this small code
pat66
May 14, 2025, 3:06pm
20
Hi everyone
my problem is solved I found what is going wrong I put
document.querySelector when I suposse to put document.getElementById.
thanks a lot for answers
1 Like