diff --git a/src/ts_node.ts b/src/ts_node.ts index 7503f5c8..b07cdf7c 100644 --- a/src/ts_node.ts +++ b/src/ts_node.ts @@ -33,19 +33,25 @@ function registerTSNode(root: string) { } else { rootDirs.push(`${root}/src`) } - tsNode.register({ - skipProject: true, - transpileOnly: true, - // cache: false, - // typeCheck: true, - compilerOptions: { - target: tsconfig.compilerOptions.target || 'es2017', - module: 'commonjs', - sourceMap: true, - rootDirs, - typeRoots, - } - }) + const cwd = process.cwd() + try { + process.chdir(root) + tsNode.register({ + skipProject: true, + transpileOnly: true, + // cache: false, + // typeCheck: true, + compilerOptions: { + target: tsconfig.compilerOptions.target || 'es2017', + module: 'commonjs', + sourceMap: true, + rootDirs, + typeRoots, + } + }) + } finally { + process.chdir(cwd) + } } function loadTSConfig(root: string): TSConfig | undefined {