Cannot figure out importing threejs

I’m following discoverthreejs.com tutorial and I’m stuck…

Steps I did:
npm init
npm i three

Created folder structure and files as needed

Pic1

In main.js I try importing:
image

Using live server I get this error…
Uncaught TypeError: Error resolving module specifier “three”. Relative module specifiers must start with “./”, “…/” or “/”. main.js:9:7

So I tried using Skypack CDN instead.


Error:

What can I try?

Do it like in this example: Edit fiddle - JSFiddle - Code Playground

  1. Use an import map that defines the three bare module specifier.
  2. Use your first approach when importing from three.
1 Like