当我使用ttsc命令编译typescript项目时,显示错误:
> yarn tscbuild
yarn run v1.22.17
$ ttsc
/Users/John/source/reddwarf/frontend/js-wheel/node_modules/resolve/lib/sync.js:111
var err = new Error("Cannot find module '" + x + "' from '" + parent + "'");
^
Error: Cannot find module 'transformer-module' from '/Users/John/source/reddwarf/frontend/js-wheel'
at Function.resolveSync [as sync] (/Users/John/source/reddwarf/frontend/js-wheel/node_modules/resolve/lib/sync.js:111:15)
at PluginCreator.resolveFactory (/Users/John/source/reddwarf/frontend/js-wheel/node_modules/ttypescript/lib/PluginCreator.js:158:34)
at PluginCreator.createTransformers (/Users/John/source/reddwarf/frontend/js-wheel/node_modules/ttypescript/lib/PluginCreator.js:120:32)
at Object.newEmit [as emit] (/Users/John/source/reddwarf/frontend/js-wheel/node_modules/ttypescript/lib/patchCreateProgram.js:76:52)
at emitFilesAndReportErrors (/Users/John/source/reddwarf/frontend/js-wheel/node_modules/typescript/lib/typescript.js:126134:23)
我错过什么了吗?我没有找到名为transformer-module
的软件包。我已经按照https://www.npmjs.com/package/ttypescript的说明安装了ttypescript。我该怎么做才能解决这个问题?transformer-module
是ttypescript的插件。它应该由ttypescript安装。
1条答案
按热度按时间67up9zun1#
参考
ttypescript
提供的示例,以及您问题中的一些信息。我想你误解了模块的工作原理。
tsconfig.json
文件中plugins
对象的transform
键必须是文件的相对或绝对路径。您可能会保留其文档中指定的值transform-module
。例如:
来源:他们的例子(https://github.com/cevek/ttypescript/blob/master/packages/ttypescript-examples/tsconfig.json)
否则,请随意给予更多的上下文,例如最小的可重复示例