Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use pnpm in my Angular project to manage packages?

I am searching for a way to have one node_modules folder to use in my different projects. I found pnpm, installed it, and created one project with the commands:

ng new test-pnpm --skip-install

ng config cli.packageManager pnpm

pnpm install

ng serve

This project doesn't start. When I delete this project and .pnpm-stor folder, I cannot install packages for the next project with pnpm.

Can anyone tell me the steps to use it in a project, how to configure, how to install, how to add packages, and how to use it in different projects?

like image 798
Mohsen Saleh Avatar asked Oct 23 '18 12:10

Mohsen Saleh


People also ask

How is Pnpm so fast?

“In pnpm, packages are always reused if they are already installed for another project saving a lot of disk space which makes it faster and more efficient than npm.”

What is Pnpm install?

pnpm install is used to install all dependencies for a project. In a CI environment, installation fails if a lockfile is present but needs an update. Inside a workspace, pnpm install installs all dependencies in all the projects. If you want to disable this behavior, set the recursive-install setting to false .

Does Pnpm work on Windows?

js version manager. See pnpm env use. Works everywhere. Supports Windows, Linux, and macOS.


1 Answers

Don't remove the .pnpm-store folder. Only remove node_modules if you want to.

Try to run pnpm install --shamefully-hoist. If it helps, you can create a .npmrc file in the root of your project with shamefully-hoist=true.

The issue is that pnpm creates a strict node_modules and sometimes packages require other packages that are not declared in their package.json. See pnpm’s strictness helps to avoid silly bugs

like image 66
Zoltan Kochan Avatar answered Sep 20 '22 22:09

Zoltan Kochan