I used to have this:
const util = require('util');
const exec = util.promisify(require('child_process').exec);
Then I refactored to this (or at least my attempt to here):
import * as exec from 'child_process';
const execPromise = util.promisify(exec);
Now I am getting the error TypeError: The "original" argument must be of type function. Received an instance of Object
on the exec
in util.promisify
Not sure how to quite get this working like it was but with this new import syntax for Typescript (specifically related to `@typescript-eslint/no-var-requires
CodePudding user response:
You're looking for
import { exec } from 'child_process';
const execPromise = util.promisify(exec);
The * as exec
did import the whole child_process module into a module namespace object.
CodePudding user response:
Try this...
import * as childProcess from 'child_process';
const execPromise = util.promisify(childProcess.exec);