66651
๐Ÿ‘€
66651
  • ๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ (57)
    • note (28)
    • log (13)
    • error (9)
    • etc (7)

๋ธ”๋กœ๊ทธ ๋ฉ”๋‰ด

  • ํ™ˆ
  • ํƒœ๊ทธ
  • ๋ฐฉ๋ช…๋ก

ํ‹ฐ์Šคํ† ๋ฆฌ

hELLO ยท Designed By ์ •์ƒ์šฐ.
66651

๐Ÿ‘€

error

[Three.js] Uncaught TypeError: Failed to resolve module specifier "three"... ์—๋Ÿฌ

Three.js ์—์„œ Uncaught TypeError: Failed to resolve module specifier "three"... ์—๋Ÿฌ ํ•ด๊ฒฐ๋ฒ•

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

 

์ถœ์ฒ˜

: https://stackoverflow.com/questions/68160473/failed-to-resolve-module-specifier-thre

: https://stackoverflow.com/questions/65697410/not-using-node-js-uncaught-typeerror-failed-to-resolve-module-specifier-thre

 

Three.js์˜ RectAreaLightUniformsLib๊ณผ ๊ฐ™์€ ES6 ๋ชจ๋“ˆ์„ ์‚ฌ์šฉํ•˜๋ ค๊ณ  ํ•˜๋ฉด ์œ„์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•  ๋•Œ๊ฐ€ ์žˆ๋‹ค.
Three.js๋ฅผ npm ๋ชจ๋“ˆ๋กœ ์„ค์น˜ํ•˜์ง€ ์•Š๊ณ  ๊ณต์‹ ์‚ฌ์ดํŠธ์—์„œ ๋ฐฐํฌํ•˜๋Š” ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œํ•ด์„œ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์ˆ˜์ •ํ•ด์ค€๋‹ค.

 

1. index.html ํŒŒ์ผ์— importmap์„ ์ถ”๊ฐ€ (๊ฒฝ๋กœ๋ฅผ ์ž˜ ํ™•์ธํ•˜๊ธฐ)

<!-- index.html -->
<script type="importmap">
    {
        "imports": {
            "three": "../three/build/three.module.js",
            "three/examples/jsm/controls/OrbitControls":"../three/examples/jsm/controls/OrbitControls.js",
        }
    }
</script>
<script type="module" src="main.js" defer></script>

 

2. ์Šคํฌ๋ฆฝํŠธ์˜ import ๋ฌธ์„ to-be ์™€ ๊ฐ™์ด ์ˆ˜์ •

// main.js

// as-is
import * as THREE from '../three/build/three.module.js'
import { OrbitControls } from '../three/examples/jsm/controls/OrbitControls.js';

// to-be
import * as THREE from 'three'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';

 

 

โ€ป importmap ์˜ ์ง€์› ๋ฒ”์œ„ : https://caniuse.com/import-maps

์ €์ž‘์žํ‘œ์‹œ (์ƒˆ์ฐฝ์—ด๋ฆผ)
    'error' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€
    • [Node.js] Cannot find module '@aws-sdk/util-endpoints' ์˜ค๋ฅ˜
    • [AWS S3] The bucket does not allow ACLs ์˜ค๋ฅ˜
    • [Webpack] Cannot find module 'sass' ์—๋Ÿฌ
    • [Gulp] Task never defined: default ์˜ค๋ฅ˜
    66651
    66651
    always awake

    ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”