12

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?

Dale K
  • 25,246
  • 15
  • 42
  • 71
Mohsen Saleh
  • 139
  • 1
  • 10

3 Answers3

13

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

Zoltan Kochan
  • 5,180
  • 29
  • 38
6

You can set pnpm directly if you're creating a new project by using the following command:

ng new test-pnpm --package-manager=pnpm

You have more options related to ng new, just check the below link: https://angular.io/cli/new

Thompson
  • 393
  • 3
  • 8
1

angular.json:

{"cli": 
  {
    "packageManager": "pnpm"
  }
}
Lauri Elias
  • 1,231
  • 1
  • 21
  • 25