You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-27Lines changed: 35 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@
8
8
9
9
Use this to load modules whose location is specified in the `paths` section of `tsconfig.json` or `jsconfig.json`. Both loading at run-time and via API are supported.
10
10
11
-
Typescript by default mimics the Node.js runtime resolution strategy of modules. But it also allows the use of [path mapping](https://www.typescriptlang.org/docs/handbook/module-resolution.html) which allows arbitrary module paths (that doesn't start with "/" or ".") to be specified and mapped to physical paths in the filesystem. The typescript compiler can resolve these paths from `tsconfig` so it will compile OK. But if you then try to execute the compiled files with node (or ts-node), it will only look in the `node_modules` folders all the way up to the root of the filesystem and thus will not find the modules specified by `paths` in `tsconfig`.
11
+
TypeScript by default mimics the Node.js runtime resolution strategy of modules. But it also allows the use of [path mapping](https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution) which allows arbitrary module paths (that doesn't start with "/" or ".") to be specified and mapped to physical paths in the filesystem. The TypeScript compiler can resolve these paths from `tsconfig` so it will compile OK. But if you then try to execute the compiled files with node (or ts-node), it will only look in the `node_modules` folders all the way up to the root of the filesystem and thus will not find the modules specified by `paths` in `tsconfig`.
12
12
13
13
If you require this package's `tsconfig-paths/register` module it will read the `paths` from `tsconfig.json` or `jsconfig.json` and convert node's module loading calls to physical file paths that node can load.
14
14
@@ -26,25 +26,31 @@ bun install --dev tsconfig-paths
26
26
27
27
### With node
28
28
29
-
`node -r tsconfig-paths/register main.js`
29
+
```bash
30
+
node -r tsconfig-paths/register main.js
31
+
```
30
32
31
-
If `process.env.TS_NODE_BASEURL` is set it will override the value of `baseUrl` in tsconfig.json:
33
+
If `process.env.TS_NODE_BASEURL` is set it will override the value of `baseUrl` in `tsconfig.json`:
If `process.env.TS_NODE_PROJECT` is set it will be used to resolved tsconfig.json
45
+
If `process.env.TS_NODE_PROJECT` is set it will be used to resolved `tsconfig.json`
40
46
41
-
### With webpack
47
+
### With Webpack
42
48
43
-
For webpack please use the [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin).
49
+
For Webpack please use the [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin).
44
50
45
51
### With mocha and ts-node
46
52
47
-
As of Mocha >= 4.0.0 the `--compiler` was [deprecated](https://github.com/mochajs/mocha/wiki/compilers-deprecation). Instead `--require` should be used. You also have to specify a glob that includes `.ts` files because mocha looks after files with `.js` extension by default.
53
+
As of Mocha >= 4.0.0 the `--compiler` was [deprecated](https://mochajs.org/explainers/compilers-deprecation/). Instead `--require` should be used. You also have to specify a glob that includes `.ts` files because mocha looks after files with `.js` extension by default.
0 commit comments