office-js - Excel JavaScript 自定义函数中的“ReferenceError:找不到变量:需要”
问题描述
我正在尝试运行需要两个第三方库的自定义函数。我将库添加到库的窗格中,如下所示:
@tensorflow/tfjs@1.5.1
@tensorflow/tfjs-node@1.4.0
sentence-tokenization@1.0.2
我收到这些错误:
{
"error": [
"ReferenceError: Can't find variable: exports",
"https://unpkg.com/@tensorflow/tfjs-node@1.4.0/dist/index.js",
32,
30,
{
"message": "Can't find variable: exports",
"line": 32,
"column": 30,
"sourceURL": "https://unpkg.com/@tensorflow/tfjs-node@1.4.0/dist/index.js",
"stack": "global code@https://unpkg.com/@tensorflow/tfjs-node@1.4.0/dist/index.js:32:30"
}
]
}
{
"error": [
"ReferenceError: Can't find variable: require",
"https://script-lab-runner.azureedge.net/",
38,
17,
{
"message": "Can't find variable: require",
"line": 38,
"column": 17,
"sourceURL": "https://script-lab-runner.azureedge.net/",
"stack": "global code@https://script-lab-runner.azureedge.net/:38:17"
}
]
}
{
"error": [
"ReferenceError: Can't find variable: require",
"https://unpkg.com/sentence-tokenization@1.0.2/tokenizers.js",
1,
19,
{
"message": "Can't find variable: require",
"line": 1,
"column": 19,
"sourceURL": "https://unpkg.com/sentence-tokenization@1.0.2/tokenizers.js",
"stack": "global code@https://unpkg.com/sentence-tokenization@1.0.2/tokenizers.js:1:19"
}
]
}
自定义函数的代码也抱怨需要,但我能够用这个解决它。
declare var require: any;
我在这里找到了建议,但不确定如何让它与库一起使用。
我错过了什么?
提前致谢。
解决方案
推荐阅读
- ruby-on-rails - 从 4.2 升级后与 Rails 5.0.6 捆绑时出现捆绑器错误
- mysql - Mariadb:赋值运算符 (:=) 不适用于局部变量
- r - 在同一轴上绘制两条线,而不会导致 y 轴上的值重叠
- node.js - Stripe 将 paymentMethod 添加到试用订阅并稍后验证信用卡
- java - 将 HATEOAS 对象作为 websocket 消息广播,其 Content-Type 不是 application/json
- javascript - 得到未捕获的类型错误:尝试清除画布时无法读取未定义或 null 的属性“getContext”
- svg - 当我们对 SVG 应用矩阵变换时,圆的半径会发生什么变化?
- mysql - 如何在sql中将日期格式从YYYY-MM-DD转换为YYYY-MM
- c# - 使用 JavaScript 动态添加表单控件并在 ASP.Net Core 中处理表单
- javascript - setTimeout 在登录页面上不起作用客户端