【问题标题】:Getting references error when importing tone.js导入tone.js时出现引用错误
【发布时间】:2021-10-27 07:04:37
【问题描述】:

我的 Mac 上有一个基本的 express.js 服务器设置。为此,我尝试按照说明导入 Tone.js,https://tonejs.github.io

npm install tone

导入 Tone.js:

import * as Tone from 'tone'

但是我收到了这个错误

未捕获的类型错误:无法解析模块说明符“tone”。相对引用必须以“/”、“./”或“../”开头。

我的包文件如下所示

{
  "name": "XXXXX",
  "version": "1.0.0",
  "description": "Run npm start",
  "main": "server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon start"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/xxxxx"
  },
  "author": "xxxxx xxxx",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/xxxxxxx"
  },
  "dependencies": {
    "express": "^4.17.1",
    "nodemon": "^2.0.12",
    "tone": "^14.7.77"
  }
}

【问题讨论】:

  • 也许仔细检查一下音调是否在 package.json 中,然后再次运行 npm install tone。
  • 是的,我都试过了:(
  • 您确定tonejs 可以在nodejs 上运行吗?
  • NodeJS 恰恰不是客户端。但这不应该阻止您将其导入 Node.js 并将其捆绑到网页上
  • 目前无法将tonejs与节点一起使用:github.com/Tonejs/Tone.js/issues/309

标签: javascript express npm npm-install tonejs


【解决方案1】:

正如@lars-flieger 指出的那样,不可能在一个 node.js 服务器上运行它。 我最终从这里下载了 Tones.js 并将其作为常规脚本标签包含在内。

https://github.com/Tonejs/Tone.js/wiki/Installation

【讨论】:

    猜你喜欢
    • 2018-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-27
    • 2021-08-10
    • 2020-09-20
    • 2018-12-27
    • 1970-01-01
    相关资源
    最近更新 更多