Typescript returns execSync 在 child_process 模块中未定义
Typescript returns execSync as undefined from the child_process module
我正在尝试使用模块 child_process 中的函数 execSync。
但是当我导入模块时:
/// <reference path="../../../../GENERAL/d.ts/node/node.d.ts" />
var execSync = require("child_process").execSync;
并尝试使用该函数,我得到一个异常,提示 execSync
未定义。
我什至尝试打印模块来检查正在导入的函数,我得到了这个结果:
{ fork: [Function],
_forkChild: [Function],
exec: [Function],
execFile: [Function],
spawn: [Function] }
正在使用的 d.ts 文件是以下文件:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts
鉴于您的节点版本是 0.10.25
我认为您需要升级节点。定义文件的第一行说 // Type definitions for Node.js v4.x
升级节点运行这个命令-
sudo npm install -g n
我正在尝试使用模块 child_process 中的函数 execSync。
但是当我导入模块时:
/// <reference path="../../../../GENERAL/d.ts/node/node.d.ts" />
var execSync = require("child_process").execSync;
并尝试使用该函数,我得到一个异常,提示 execSync
未定义。
我什至尝试打印模块来检查正在导入的函数,我得到了这个结果:
{ fork: [Function],
_forkChild: [Function],
exec: [Function],
execFile: [Function],
spawn: [Function] }
正在使用的 d.ts 文件是以下文件:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts
鉴于您的节点版本是 0.10.25
我认为您需要升级节点。定义文件的第一行说 // Type definitions for Node.js v4.x
升级节点运行这个命令-
sudo npm install -g n