gulp 构建项目:‘ error TS6082: Only ‘amd‘ and ‘system‘ modules are supported alongside --outFile.’

gulp 打包 node ts项目

报错

error TS6082: Only ‘amd’ and ‘system’ modules are supported alongside --outFile.

➜  gateway git:(test) ✗ npm run build

> gateway@1.0.0 build
> gulp build

[16:26:30] Using gulpfile ~/Desktop/gateway/gulpfile.js
[16:26:30] Starting 'build'...
[16:26:30] Starting 'clean'...
[16:26:30] Finished 'clean' after 3.88 ms
[16:26:30] Starting 'toJs'...
error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile.
TypeScript: 1 options error
TypeScript: emit succeeded (with errors)
[16:26:31] 'toJs' errored after 1.2 s
[16:26:31] Error: TypeScript: Compilation failed

–outFile 仅支持“amd”和“system”模块。 这主要是 gulp 配置中可能多次使用了输出文件的地址指定

原因

在 ts.createProject 中多出配置 outFile: ‘dist’

在这里插入图片描述

解决

如图,删除此配置即可构建成功

在这里插入图片描述
构建正常

➜  gateway git:(test) ✗ npm run build

> gateway@1.0.0 build
> gulp build

[16:29:31] Using gulpfile ~/Desktop/gateway/gulpfile.js
[16:29:31] Starting 'build'...
[16:29:31] Starting 'clean'...
[16:29:31] Finished 'clean' after 4.44 ms
[16:29:31] Starting 'toJs'...
[16:29:32] Finished 'toJs' after 1.27 s
[16:29:32] Finished 'build' after 1.27 s

在这里插入图片描述


版权声明:本文为zc135565原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。