Reputation: 173
I am drawing a blank in bed right now, and after a bunch of google searches and incomplete answers I decided to ask here.
Can anyone explain to me how the scoping works for import in typescript to know to go check the package.json? For example, you do something like import * from ‘three’. What tells typescript to go to the package.json to check for three?
Upvotes: 1
Views: 108
Reputation: 68645
When your moduleResolution
is set to node
the modules are required via require()
like in NodeJS. The rest is explained in the documentation.
From the Documentation
If the module identifier passed to require() is not a core module, and does not begin with '/', '../', or './', then Node.js starts at the parent directory of the current module, and adds /node_modules, and attempts to load the module from that location. Node will not append node_modules to a path already ending in node_modules.
Upvotes: 1