Caching: So that when we require this file again, we don’t go over all the steps another time. ![]() Evaluating: This is what the VM eventually does with the loaded code.This is what makes both the require and module objects local to every file we require. Wrapping: To give the file its private scope.Loading: To determine the type of the file content.Resolving: To find the absolute path of the file.When Node invokes that require() function with a local file path as the function’s only argument, Node goes through the following sequence of steps: The main object exported by the require module is a function (as used in the above example). ![]() Requiring a module in Node isn’t that complicated of a concept. You can think of the require module as the command and the module module as the organizer of all required modules.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |