This is an alpha, sneak peek of Monorepo Maestros. For this iteration, I'm getting all of my thoughts down. In the future, we'll have better information architecture, graphics, and other awesomeness. Your feedback is welcome!

npm

npm was the first JavaScript package manager, setting the standard for all of the package managers that we have today. npm comes bundled with the Node.js runtime and is the default package manager for the JavaScript ecosystem and supports monorepos through workspaces.

Setting up workspaces

To create your workspaces, you'll need a workspaces field in your package.json:

package.json
{
"name": "my-repo",
"private": true,
"scripts": { ... },
"devDependencies": { ... },
"packageManager": "npm@8.5.0", // Needed for Turborepo
"workspaces": ["apps/*", "packages/*"]
}
package.json
{
"name": "my-repo",
"private": true,
"scripts": { ... },
"devDependencies": { ... },
"packageManager": "npm@8.5.0", // Needed for Turborepo
"workspaces": ["apps/*", "packages/*"]
}

Now, any directory in your apps and packages directories that contains a package.json will be treated as a workspace.

  • package.json
  • package-lock.json
  • apps
    • docs (Workspace!)
    • web (Workspace!)
  • packages
    • logger (Workspace!)
    • ui (Workspace!)
  • To begin building packages, see the packaging page.

    To begin building apps, see the applications page.

    Tips and tricks

    Workspace-specific commands

    Say you want to run an npm command in a specific workspace. This can be done using the --workspace argument (-w for short). The value is your workspace's name from package.json.

    Terminal
    npm install react -w @repo/ui
    Terminal
    npm install react -w @repo/ui