【发布时间】:2021-12-30 07:09:48
【问题描述】:
作品(文件为gulpfile.ts):
const Gulp = require("gulp");
不起作用(没有 TypeScript 错误,但 Gulp 是 undefined):
import Gulp from "gulp";
tsconfig.json:
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"strict": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"allowJs": false,
"skipLibCheck": true,
"baseUrl": "./",
"paths": {}
}
}
命令:
gulp <Any declared Gulp task>
【问题讨论】:
-
gulpfile.ts长什么样?不正确的导出逻辑可能导致意外行为 -
@Leemellaret,感谢您的评论。只需
import Gulp from "gulp"; console.log(Gulp);就足以实现最小的复制。当然,Gulp 会告诉Task never defined: Deploy,但在此之前会输出undefined。如果将第一行替换为var Gulp = require("gulp");,undefined将消失。
标签: typescript gulp ts-node