@Tobbe
These notes will help you replace âyarnâ with âpnpmâ
a. Remove lerna.json and yarn.lock
b. In the rootâsâ package.json, add this:
"workspaces": [
"packages/*"
],
c. When you use pnpm on a project, you donât want others to accidentally run npm install or yarn. To prevent devs from using other package managers, you can add the following preinstall script to your package.json:
{
"scripts": {
"preinstall": "npx only-allow pnpm"
...
}
}
Now, whenever someone runs npm install or yarn, theyâll get an error instead and installation will not proceed.
d. Create a file name, pnpm-workspace.yaml in the root with the following contents:
packages:
- 'packages/*'
e. Install the dependencies
cd redwood
pnpm --ignore-scripts install
f. Add a dependency module using pnpm
pnpm add express Save to dependencies
pnpm add -D express Save to devDependencies
pnpm add -O express Save to optionalDependencies
g. When adding, removing, or updating dependencies within a workspace, you need to go that workspaceâs folder first
cd packages/api
pnpm add csurf cookie-parser
cd packages/web
pnpm remove react-hot-toast
h. Run a script defined in the packageâs file from the command prompt:
pnpm run *script-name*
i. Replacing âyarnâ commands with âpnpmâ in the pakage.json
yarn lint ---> pnpm run lint
yarn jest ---> pnpm run jest
j. Replacing âlerna runâ and âlerna publishâ commands with âpnpmâ in the pakage.json, these links may help
https://pnpm.io/cli/publish
https://pnpm.io/workspaces