Node.js Runtime Environment

  1. Node.js Module Systems
    1. CommonJS Modules
      1. Module Structure and Syntax
        1. require Function
          1. Loading Local Modules
            1. Loading Core Modules
              1. Loading Third-Party Modules
                1. Module Resolution Algorithm
                2. module.exports Object
                  1. Exporting Functions
                    1. Exporting Objects
                      1. Exporting Classes
                      2. exports Shortcut
                        1. Usage and Limitations
                          1. Common Pitfalls
                          2. Module Caching
                            1. How Caching Works
                              1. Cache Invalidation
                                1. require.cache Object
                              2. ES Modules
                                1. Module Structure and Syntax
                                  1. import Statement
                                    1. Importing Default Exports
                                      1. Importing Named Exports
                                        1. Importing All Exports
                                          1. Dynamic Imports
                                          2. export Statement
                                            1. Exporting Functions
                                              1. Exporting Objects
                                                1. Exporting Variables
                                                  1. Default Exports
                                                    1. Re-exports
                                                    2. Top-level await
                                                      1. Use Cases and Limitations
                                                        1. Module Loading Implications
                                                        2. Interoperability with CommonJS
                                                          1. Importing CommonJS in ESM
                                                            1. Importing ESM in CommonJS
                                                              1. createRequire Function
                                                            2. The package.json File
                                                              1. Core Properties
                                                                1. name
                                                                  1. version
                                                                    1. main
                                                                      1. scripts
                                                                        1. description
                                                                          1. author
                                                                            1. license
                                                                              1. keywords
                                                                              2. Module Configuration
                                                                                1. type Field
                                                                                  1. exports Field
                                                                                    1. imports Field
                                                                                    2. Managing Dependencies
                                                                                      1. dependencies
                                                                                        1. devDependencies
                                                                                          1. peerDependencies
                                                                                            1. optionalDependencies
                                                                                            2. Custom Scripts
                                                                                              1. Defining Scripts
                                                                                                1. Running Scripts
                                                                                                  1. Pre and Post Hooks