How to switch from NPM/Yarn to PNPM
If you wonder why many people switch to PNPM, let this image tell you
If you wonder why to switch from NPM/Yarn to PNPM, let this image tell you
I think you know now. let's start with installing PNPM
$ npm install -g pnpm
After you have installed it, Now let’s remove the old node_modules
$ rm -rf node_module
Replace the package manager to pnpm
with this command
$ pnpm import
and the useless *-lock.json
file depends on witch file you have in your project e.g. (package-lock.json
yarn-lock.json
)
// remove yarn-lock and package-lock.json
$ rm -rf yarn.lock yarn-lock.json package-lock.json
And then reinstall the dependency
$ pnpm install
Now you can run your project with thepnpm
like $ pnpm start
or whatever you set in the package.json
Using a shorter alias
pnpm
might be hard to type, so you may use a shorter alias like pn
instead. Just put the following line to your .bashrc
, .zshrc
, or config.fish
:
alias pn=pnpm