Switching from pnpm to npm while continuing with a monorepo (a system for managing multiple applications).
The AWS Amplify CLI has long supported npm Workspaces, which is ideal for implementing monorepos.
Steps to Switch from pnpm to npm Workspaces
The goal is to unify the package manager to npm by creating a new package-lock.json in the project root and deleting pnpm-lock.yaml.
1. Clean up pnpm-related files and existing node_modules
- Delete the
pnpm-lock.yamlfile in the root directory. → DONE - Delete the
node_modulesdirectories in the root directory and in all app/package directories (workspaces). → DONE
2. Configure the Root package.json
Migrate the pnpm configuration (usually found in pnpm-workspace.yaml) to the npm Workspaces configuration.
- Open the root
package.jsonand add the"workspaces"field. → DONE
3. Reinstall Dependencies
Execute the npm install command in the root directory to create a new package-lock.json. Run the following command in the root directory:
Bash
npm install
An error occurred because all projects' package.json names were the same, which is not allowed (NG).
I changed the names. The apparent rule is to write them like this when my-app is the parent: "@my-app/web-app".
The migration from pnpm to npm is now temporarily complete.
Installing Amplify
I used the following command to install Amplify:
Bash
npx @aws-amplify/backend-cli sandbox
Note: It seems the command amplify sandbox does not work.
Next Steps (Starting Tomorrow)
Tomorrow, I will continue with the following:
Bash
npx ampx configure profile
- Input the AWS Access Key ID and AWS Secret Access Key.
Top comments (0)