Introduction to pnpm, the reduction of npm alternatives saves you disk space
I recently wrote an article about how we have huge
node_modulesFolder, why is this not necessarily a bad thing, but it can reduce hard drive consumption, right?
Every byte saved on the disk can be used for other purposes besides library code. I had a 512GB SSD on the MacBook Pro I bought in 2010, but some brand new computers in 2019 came with a 128GB SSD. hard disk space).
In particular, one approach is to centralize library code storage in a central location and share it with all the projects you work on.
This is the main value proposition of...pm, This is a very cool project, you can check it out athttps://pnpm.js.org.
It is basically a substitute
npm, Which means that once you install it, you can call
pnpm installDownload the project dependencies, all of which will work transparently for you.
If you have 10 projects that use the same version of React,
pnpmIt will be installed once, and then the installation will be referenced first in all other projects.
This also means that compared to having to use standard download resources, the initial part of the project takes much less time.
npmprogram. Even faster
npmCache package because
pnpmHard-linked to the central local repository, while
npmCopy the package from the cache.
npm install -g pnpm
And then be
pnpmAlternative products, you can use all
pnpm install react pnpm update react pnpm uninstall react
and many more.
pnpmIt is especially appreciated in companies that need to maintain a large number of projects with the same dependencies.
E.gglitchIs one of them because they host huge Node.js projects.
pnpmTo them except
npmCommon commands, some utilities include
pnpm recursiveTo run the same command on all items in the folder. For example, you can initialize 100 items stored in the current folder by running
pnpm recursive install. convenient.
If you use
npx, This is to run the utility (such as
create-react-app, The benefits you will get
pnpx create-react-app my-cool-new-app
Where is the package installed? In macOS,
~Represents your home folder). I installed
lodashAs an example, this is the resulting folder structure:
➜ ~ tree .pnpm-store/ .pnpm-store/ └── 2 ├── _locks ├── registry.npmjs.org │ └── lodash │ ├── 4.17.11 │ │ ├── integrity.json │ │ ├── node_modules │ │ │ └── lodash │ │ │ ├── ... │ │ ├── package -> node_modules/lodash │ │ └── packed.tgz │ └── index.json └── store.json
There is a lot of more advanced knowledge to learn about this tool, but I hope this can help you get started.
Should you use it for daily use? Probably not, just insist
npmUnless you have a problem that you need the tool to solve for you-lack of disk space is one of them.
Download mine for freeNode.js manual
More node tutorials:
- Introduction to npm package manager
- Introduction to Node.js
- HTTP request using Axios
- Where to host Node.js applications
- Use Node.js to interact with Google Analytics API
- npx node package runner
- package.json guide
- Where does npm install packages?
- How to update Node.js
- How to use or execute packages installed with npm
- package-lock.json file
- Semantic version control using npm
- Should you submit the node_modules folder to Git?
- Update all Node dependencies to the latest version
- Use Node.js to parse JSON
- Find the installed version of the npm package
- Node.js flow
- Install an older version of the npm package
- Get the current folder in Node
- How to record objects in Node
- Use export to expose functions from Node files
- Difference between node and browser
- Use Node to make HTTP POST requests
- Use Node to get HTTP request body data
- Node buffer
- A brief history of Node.js
- How to install Node.js
- How to use Node.js REPL
- Node, accepts parameters from the command line
- Use Node to output to the command line
- Accept input from the command line in Node
- Use `npm uninstall` to uninstall the npm package.
- npm global or local package
- npm dependencies and devDependencies
- Node.js event loop
- Understanding process.nextTick()
- Understanding setImmediate()
- Node event emitter
- Set up an HTTP server
- Use Node to make HTTP requests
- Node fs module
- HTTP request in Node using Axios
- Use Node to read files
- Node file path
- Write file with Node
- Node file statistics
- Use file descriptors in Node
- Use folders in Node
- Node path module
- Node http module
- Combine WebSockets with Node.js
- Basic knowledge of using MySQL and Node
- Error handling in Node.js
- Pug Guide
- How to read environment variables from Node.js
- How to exit from Node.js program
- Node os module
- Node event module
- Node, the difference between development and production
- How to check if a file exists in Node.js
- How to create an empty file in Node.js
- How to delete files using Node.js
- How to get the last update date of a file using Node.js
- How to write a JSON object to a file in Node.js
- Why use Node.js in the next project?
- Run web server from any folder
- How to use MongoDB with Node.js
- Use Chrome DevTools to debug Node.js applications
- What is pnpm?
- Node.js runtime v8 options list
- How to solve the "missing write access permission" error when using npm
- How to enable ES modules in Node.js
- How to use Node.js to generate child processes
- How to get the parsed body and the original body at the same time in Express
- How to handle file upload in Node.js
- What is the peer dependency in the node module?
- How to write a CSV file using Node.js
- How to use Node.js to read CSV files
- Node core module
- Use Node.js to increase the number of multiple folders at once
- How to print canvas to data URL
- How to create and save images using Node.js and Canvas
- How to download images using Node.js
- How to batch rename files in Node.js
- How to get the names of all files in a folder in Node
- How to use promise and wait function based on Node.js callback
- How to test NPM packages locally
- How to check the current Node.js version at runtime
- How to use Sequelize to interact with PostgreSQL
- Use Node.js to serve HTML pages
- How to solve the error that util.pump in Node.js is not a function