简体   繁体   中英

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:

SyntaxError: Unexpected token export

I don't want to compile it to normal JavaScript, because than i will have to compile local files too.

In npm i have:

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

source code

您可以通过直接指向包中的打字稿文件来简单地做到这一点:

import {startGenerateClientApi} from 'nest-client-generator/your_path_to_ts_file'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM