我有一个代码
import * as path from 'path';
import * as globby from 'globby';
import { execFile } from 'child_process';
import * as util from 'util';
//import * as Promise from 'bluebird';
import * as fs from 'fs';
execFile = util.promisify(execFile);
编译为js时
显示错误日志
Error:(12, 1) TS2539:Cannot assign to 'execFile' because it is not a variable.
我应该以正确的方式重写代码以解决这个问题,或者只是保持原状
答案 0 :(得分:0)
在types
中为您的tsconfig设置compilerOptions
,就像这样
"compilerOptions": {
"target": "es5",
"lib": [ "es2015"],
"types": ["node"],
"module": "commonjs"
}