--moduleResolution
flag to specify the module resolution strategy. If not specified, the default is
Classic for
--module AMD | System | ES2015
or
Node otherwise.
For non-relative module imports, however, the compiler walks up the directory tree starting with the directory containing the importing file, trying to locate a matching definition file.html
For example:node
A non-relative import to moduleB
such as import { b } from "moduleB"
, in a source file /root/src/folder/A.ts
, would result in attempting the following locations for locating "moduleB"
:typescript
/root/src/folder/moduleB.ts
/root/src/folder/moduleB.d.ts
/root/src/moduleB.ts
/root/src/moduleB.d.ts
/root/moduleB.ts
/root/moduleB.d.ts
/moduleB.ts
/moduleB.d.ts
/root/src/node_modules/moduleB.js
/root/src/node_modules/moduleB/package.json
(if it specifies a "main"
property)/root/src/node_modules/moduleB/index.js
/root/node_modules/moduleB.js
/root/node_modules/moduleB/package.json
(if it specifies a "main"
property)/root/node_modules/moduleB/index.js
/node_modules/moduleB.js
/node_modules/moduleB/package.json
(if it specifies a "main"
property)/node_modules/moduleB/index.js