As added in #181 ts-node accepts a --require flag. When trying to use this with the tsconfig-paths package it fails to locate the package. Example:
$ ts-node -r tsconfig-paths main.ts
Error: Cannot find module 'tsconfig-paths'
The reason seems to be this line which does Module._load(id) in order to require the modules specified by --require. If it is changed to require(id)it will locate the package. It seems like Module._load(id) skips loading from node_modules.
The mocha package also has a -r option and looking here it seems they use require to load the modules rather than Module._load. So this example works:
$ mocha --compilers ts:ts-node/register -r node-tsconfig-paths mocha-example.ts
As added in #181 ts-node accepts a --require flag. When trying to use this with the tsconfig-paths package it fails to locate the package. Example:
The reason seems to be this line which does
Module._load(id)in order to require the modules specified by--require. If it is changed torequire(id)it will locate the package. It seems likeModule._load(id)skips loading fromnode_modules.The
mochapackage also has a-roption and looking here it seems they userequireto load the modules rather thanModule._load. So this example works: