I had wroten a pure typescript npm module(without any .js file), and want to use it in my server project which use ts-node(without any compile work like tsc) to run directly. because my case is a server environment, so startup time is not a problem.
the problem is: ts-node cannot use import to load pure typescript inside node_modules directory, I had to do a little hack(move it out, use soft link to link it back).
$ npm install
$ ts-node bin/index.ts
/Users/zixia/git/wechaty.io/node_modules/wechaty-io/index.ts:1
(function (exports, require, module, __filename, __dirname) { export * from './src/io-server'
^^^^^^
SyntaxError: Unexpected token export
my hack is: move wechaty-io module directory out of node_modules, then use soft link to link it back
$ npm install
$ mv node_modules/wechaty-io .
$ ln -s ../wechaty-io node_modules/
$ ts-node bin/index.ts
info io-server Listening on 8080
info io-server init succeed
It seems the import in ts-node will not work when the pure typescript module is in node_modules directory. But, after we changed the physics directory out of node_modules directory, ts-node will make import work properly.
Is there any better solution to do this? Thanks.
Isn't this a duplicate of https://github.com/TypeStrong/ts-node/issues/155? We don't enable TypeScript modules in node_modules, node modules should be JavaScript.
Isn't this a duplicate of #155? We don't enable TypeScript modules in node_modules, node modules should be JavaScript.
That's look weird, because we have got a lot libraries which doesn't compiled properly..
Is there any option to replace import folder for node_modules? Or disable node_modules ignoring?
@glebmachine Sure. Check the README or the linked issue.