【问题标题】:Relative reference error when import node module three js导入节点模块三js时的相对引用错误
【发布时间】:2021-06-21 20:54:15
【问题描述】:

尝试从 three.js 导入 GLTFLoader(通过 npm 加载)但在下面出现此错误,这是我的导入(尝试添加 '/'、'./' 和 '../' 相同的错误)

错误

 index.html:1 Uncaught TypeError: Failed to resolve module specifier 
    "node_modules/three/examples/jsm/loaders/GLTFLoader.js". Relative 
    references must start with either "/", "./", or "../".   

导入

const THREE = require('three'); //works
import { GLTFLoader } from 'node_modules/three/examples/jsm/loaders/GLTFLoader.js';//error

【问题讨论】:

    标签: javascript web three.js


    【解决方案1】:

    简单使用:

    从“三个/examples/jsm/loaders/GLTFLoader.js”导入{ GLTFLoader};

    应该可以正常工作(没有node_modules)。

    【讨论】:

    • 抱歉没用,我这边没问题。我猜你已经检查了文件node_modules/three/examples/jsm/loaders/GLTFLoader.js 是否可用?
    • 是的,它也适用于我的其他工作区,但我不知道,无论如何谢谢
    猜你喜欢
    • 1970-01-01
    • 2016-03-07
    • 2017-05-19
    • 1970-01-01
    • 2018-12-28
    • 2018-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多