![](/img/trans.png)
[英]TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type Function. Received type undefined
[英]The "original" argument must be of type function. Received an instance of Object
我曾經有過這個:
const util = require('util');
const exec = util.promisify(require('child_process').exec);
然后我對此進行了重構(或者至少是我在這里的嘗試):
import * as exec from 'child_process';
const execPromise = util.promisify(exec);
現在我收到錯誤TypeError: The "original" argument must be of type function. Received an instance of Object
on the exec
in util.promisify
不知道如何讓它像以前一樣工作,但使用 Typescript 的新導入語法(特別與` @typescript-eslint/no-var-requires相關
您正在尋找
import { exec } from 'child_process';
const execPromise = util.promisify(exec);
* as exec
確實將整個child_process模塊導入到模塊名稱空間 object 中。
嘗試這個...
import * as childProcess from 'child_process';
const execPromise = util.promisify(childProcess.exec);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.