【问题标题】:Node npm - referencing three.js module on the front endNode npm - 在前端引用three.js 模块
【发布时间】:2017-01-11 21:31:15
【问题描述】:

我目前正在使用节点 npm 来管理前端的 jquery 等依赖项。使用以下方法。

服务器(工作)

app.use('/jquery', express.static(__dirname + '/node_modules/jquery/dist/'));

客户(工作)

<script src="/jquery/jquery.js"></script>

这可行,但我也希望能够从服务器端管理依赖项“three.js”。有点像...

服务器(不工作)

app.use('/three', express.static(__dirname + '/node_modules/three/dist/'));

客户端(不工作)

<script src="/three/three.js"></script>

错误()

加载资源失败,服务器响应状态为 404(未找到)

如何找到 npm 模块的目录结构?

【问题讨论】:

    标签: javascript node.js npm three.js


    【解决方案1】:

    在three.js项目中,构建的文件位于build目录,而不是dist

    在服务器上,这应该可以工作:

    app.use('/three', express.static(__dirname + '/node_modules/three/build/'));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-20
      • 2014-11-19
      • 2017-03-19
      • 2013-10-01
      相关资源
      最近更新 更多