Office js &引用;引用错误:Can';t查找变量:require";Excel中的JavaScript自定义函数

Office js &引用;引用错误:Can';t查找变量:require";Excel中的JavaScript自定义函数,office-js,custom-functions-excel,scriptlab,Office Js,Custom Functions Excel,Scriptlab,我正在尝试运行一个需要两个第三方库的自定义函数。我将库添加到“库”窗格中,如下所示: @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/tf

我正在尝试运行一个需要两个第三方库的自定义函数。我将库添加到“库”窗格中,如下所示:

@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"
        }
    ]
}
自定义函数的代码也抱怨require,但我能够用这个解决它

declare var require: any;
我找到了这个建议,但不确定如何让它与图书馆合作

我错过了什么


提前谢谢。

您想试试这个吗<代码>npm安装--保存dev@types/node。Use typescript v2Excel在web浏览器上下文中运行JavaScript。Nodejs包不可用