Node.js TypeError:The";“原件”;参数必须是Function类型

Node.js TypeError:The";“原件”;参数必须是Function类型,node.js,reactjs,webpack,tfjs-node,Node.js,Reactjs,Webpack,Tfjs Node,我在尝试在我的electron react应用程序中要求tfjs节点时遇到此错误。这个问题在我没有安装react之前没有发生过,我认为这是由于网页中的某些内容需要配置 const tf = require('@tensorflow/tfjs-node'); 错误日志: Uncaught TypeError: The "original" argument must be of type Function at Object.promisify (util.js:601) at

我在尝试在我的electron react应用程序中要求tfjs节点时遇到此错误。这个问题在我没有安装react之前没有发生过,我认为这是由于网页中的某些内容需要配置

const tf = require('@tensorflow/tfjs-node');
错误日志:

Uncaught TypeError: The "original" argument must be of type Function
    at Object.promisify (util.js:601)
    at Object.<anonymous> (file_system.js:58)
    at Object../node_modules/@tensorflow/tfjs-node/dist/io/file_system.js (file_system.js:359)
    at __webpack_require__ (bootstrap:785)
    at fn (bootstrap:150)
    at Object../node_modules/@tensorflow/tfjs-node/dist/index.js (index.js:34)
    at __webpack_require__ (bootstrap:785)
    at fn (bootstrap:150)
    at Object../src/components/ssd/image_utils.js (image_utils.js:2)
    at __webpack_require__ (bootstrap:785)
    at fn (bootstrap:150)
    at Object.<anonymous> (ssd.js:1)
    at Object../src/components/ssd/ssd.js (ssd.js:196)
    at __webpack_require__ (bootstrap:785)
    at fn (bootstrap:150)
    at Object../src/components/recorder/screen_utils.js (screen_utils.js:5)
    at __webpack_require__ (bootstrap:785)
    at fn (bootstrap:150)
    at Module../src/components/recorder/Recorder.js (Recorder.css?0341:45)
    at __webpack_require__ (bootstrap:785)
    at fn (bootstrap:150)
    at Module../src/Router.js (index.css:7)
    at __webpack_require__ (bootstrap:785)
    at fn (bootstrap:150)
    at Module../src/index.js (index.css?f3f6:45)
    at __webpack_require__ (bootstrap:785)
    at fn (bootstrap:150)
    at Object.1 (serviceWorker.js:141)
    at __webpack_require__ (bootstrap:785)
    at checkDeferredModules (bootstrap:45)
    at Array.webpackJsonpCallback [as push] (bootstrap:32)
    at main.chunk.js:1

问题在于需求。“@tensorflow/tfjs node”导出多个内容(可能),因此此模块内的导出类似于

module.exports = {
    firstThing,
    secondThing, ...
}
因此,代码中的tf是一个对象,而不是一个函数。所以,您应该像这样使用命名导入

const {tf} = require('@tensorflow/tfjs-node')
因此,在调用tf时会出现错误。我没有使用过这个软件包,但这似乎是导致错误的原因。如果无法解决问题,请添加引发错误的行

const {tf} = require('@tensorflow/tfjs-node')