We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
Episode 02 - Igniting our app What is NPM ? ● NPM is a package manager.
● It is the world’s largest
software registry. ● Open source developers from every continent use npm to share and borrow packages and many organizations use npm to manage private development as well. ● It consists of three components: ○ The website ○ The command line interface ○ The registry ● Use npm to: ○ Adapt packages of code for your apps, or incorporate packages as they are. ○ Download standalone tools you can use right away. ○ Run packages without downloading using npx. ○ Share code with any npm user anywhere. ○ Restrict code to specific developers. ○ Create organizations to coordinate package maintenance, coding and developers. ○ Manage multiple versions of the code and code dependencies. ○ Update applications easily when underlying code is updated. What is a package.json file ? ● The package.json file is the heart of the node.js system. Aditya Kharadkar 12 ● It is the manifest file of any node.js project and contains the metadata of the project. ● This metadata information can be categorized into below categories: ○ Identifying metadata properties: It basically consists of the properties to identify module/project such as the name of the project, current version of the module, license, author of the project, description about the project, etc. ○ Functional metadata properties: It consists of the functional values/properties of the project/module such as entry/starting point of the module, dependencies in project scripts being used, repository link, etc. What is a bundler ? ● A JavaScript bundler is a tool that puts your code and all its dependencies together in one JavaScript file. ● It is a development tool that combines many JavaScript code files into a single one that is production-ready loadable in the browser. ● Following are the top 5 bundlers in JavaScript: ○ Browserify ○ ESbuild ○ Parcel ○ Rollup ○ Webpack Package.json is a configuration for npm. Create-react-app uses webpack bundler behind the scenes. Aditya Kharadkar 13 There are 2 types of dependencies in the package we install: 1. Dev dependencies 2. Normal dependencies Caret and Tilde in package.json 1. Tilde (~) Notation a. The Tilde (~) notation is employed to match the latest patch version while freezing the major and minor versions. b. This notation is useful for automatically updating the bug fixes, considering that patch updates primarily update bugs. 2. Caret (^) Notation a. It automatically updates both minor and patch updates. b. This is used as default notation by npm. c. If the current version of a package is ^1.2.4, and tomorrow if there is an upgrade in the package and we get a new version i.e. 1.2.5, then (^) will automatically upgrade 1.2.4 to 1.2.5. d. Caret helps in upgrading the minor versions whereas tilde helps in upgrading the major versions. What is the role of the package-lock.json file ? ● The package-lock.json file in npm simply serves as a lockfile that captures the exact versions of packages and their dependencies. ● It ensures that the same version of packages is used across different installations or environments. ● This consistency prevents unexpected package versions and helps avoid compatibility issues. Aditya Kharadkar 14 ● When you install or update packages using npm, it checks the package-lock.json file to ensure the specified versions are installed. ● This lockfile is especially important when collaborating on projects as it guarantees that all the contributors use consistent package versions. Transitive Dependencies ● When a dependency has its own dependencies and those dependencies have their own dependencies, then it is known as transitive dependencies. ● In the React project, inside node modules, every dependency folder has its own package.json file which contains the dependencies and the description of that dependency. Why should we not push the node_modules to git or production ? ● Node modules are huge in size. ● If we have package.json and package-lock.json, then we can recreate the node modules anytime. ● This is why it is not recommended to push the node modules
Docker: The Complete Guide to the Most Widely Used Virtualization Technology. Create Containers and Deploy them to Production Safely and Securely.: Docker & Kubernetes, #1
Software Containers: The Complete Guide to Virtualization Technology. Create, Use and Deploy Scalable Software with Docker and Kubernetes. Includes Docker and Kubernetes.