Reputation: 2267
I'm new to Angular. In an angular application, I find this reference very weird...
import * as moment from 'moment';
Where does this 'from moment' reside in? How does the application know where 'moment' is?
I'm using visual studio code.
Thanks
Upvotes: 0
Views: 26
Reputation: 2879
Moment is a package in your /node_modules/
folder. It is an external package for time conversions and calculations that has been installed from the npm registry.
Your code is compiled with the typescript compiler.
The settings for the compiler are located in the tsconfig.json
in your project.
In there you will find a row:
"moduleResolution": "node"
Which tells typescript that you are using a node.js environment with all installed packages being located in the /node_modues
/ folder
With the "node"
option set, typescript will look both in the current folder as well as in the node_modules
folder to find the needed modules.
You can find out more about module resolution in typescript here: https://www.typescriptlang.org/docs/handbook/module-resolution.html
Upvotes: 1