Package Managers¶
Unlock the power of open source
What are package managers?¶
- Developer tools that allows access to libraries
Examples
- JavaScript (NPM/Yarn)
- Python(Pip/Poetry)
Diagram of the Package Manager Data Flow
Modern Infrastructure Dependency
Examples of Actual Libraries and their dependencies¶
See this tool to visualise dependency.
MUI Dependency
Express Dependency
Install Package Managers¶
- NPM Download | Node.js (nodejs.org)
-
Yarn Installation | Yarn (yarnpkg.com)
-
Pip Download Python | Python.org
- Poetry Poetry - Python dependency management and packaging made easy (python-poetry.org)
Actual Examples of Real-World Projects and their dependencies¶
Foodbank package.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
-
Package Headers and Meta Information (line 2-20)
Contains some meta information about the project. Eg. used for publication in npmjs.org
-
Scripts
Alias of commands to run using the modules in the dependency
1
yarn start // yarn [script-name]
or
1
npm run start // npm run [script-name]
-
Dependencies
Libraries that are used in the project
To add a dependency, run
1
yarn add formik // yarn add [library-name]
or
1
npm install formik // npm install [library-name]
-
Dev-Dependencies
Libraries that are used in the project on development environments Typically: linters, and testers
1
yarn add -D prettier // yarn add -D [library-name]
or
1
npm install -D prettier // npm install -D [library-name]
Lockfiles¶
It locks the dependencies and sub dependencies (dependency of dependency) of your application the last time it installed correctly.
Files:
- package-lock.json
- Yarn-lock.json
- Poetry.lock
E.g. wais/yarn.lock at main · codersforcauses/wais (github.com)
When to install globally?¶
Whenever installing package, it is recommended to install it for a specific project The only thing you should really install globally are CLI tools. Even then, you have npx
1 |
|
1 |
|
Firebase CLI
1 |
|
Demo - Material UI¶
- Create a react-app
npx create-react-app mui-demo
- Move directory
cd mui-demo
- Install react-spring
yarn add @mui/material @mui/icons-material
- Start the app
yarn start
- Show Bottom Navigation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
import * as React from 'react'; import BottomNavigation from '@mui/material/BottomNavigation'; import BottomNavigationAction from '@mui/material/BottomNavigationAction'; import FolderIcon from '@mui/icons-material/Folder'; import RestoreIcon from '@mui/icons-material/Restore'; import FavoriteIcon from '@mui/icons-material/Favorite'; import LocationOnIcon from '@mui/icons-material/LocationOn'; export default function LabelBottomNavigation() { const [value, setValue] = React.useState('recents'); const handleChange = (event, newValue) => { setValue(newValue); }; return ( <BottomNavigation sx={{ width: 500 }} value={value} onChange={handleChange}> <BottomNavigationAction label="Recents" value="recents" icon={<RestoreIcon />} /> <BottomNavigationAction label="Favorites" value="favorites" icon={<FavoriteIcon />} /> <BottomNavigationAction label="Nearby" value="nearby" icon={<LocationOnIcon />} /> <BottomNavigationAction label="Folder" value="folder" icon={<FolderIcon />} /> </BottomNavigation> ); }