[英]How to using typescript from npm package
I have some "compiler" package that generates some typescript classes.我有一些“编译器”包,可以生成一些打字稿类。
So, when i tried to run it through npm i got this error:因此,当我尝试通过 npm 运行它时,出现此错误:
SyntaxError: Unexpected token export
I don't want to compile it to normal JavaScript, because than i will have to compile local files too.我不想将它编译为普通的 JavaScript,因为我也必须编译本地文件。
In npm i have:在 npm 我有:
export {startGenerateClientApi} from './api.gen'
export {startGenerateInterfaces} from './i18n.gen'
and i just import:我只是导入:
import {startGenerateClientApi} from 'nest-client-generator'
Than i run it with ts-node比我用 ts-node 运行它
您可以通过直接指向包中的打字稿文件来简单地做到这一点:
import {startGenerateClientApi} from 'nest-client-generator/your_path_to_ts_file'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.