I checked out a repo which uses yarn instead of npm as build tool.
in the package.json, it defines workspaces to deal with multiple sub-projects:
{ "workspaces": [ "packages/*" ], "dependencies": [], "devDependencies": [ // long list ] }
As a result, the root package.json
does not contain any runtime dependency. Just the packages/*/package.json
contain those.
To compile (and start in dev mode) I do:
yarn install yarn start
I have found no documentation, that workspaces
is also recognized and correctly used by npm.
Is there a way to make it work with npm, too?
Yarn can consume the same package. json format as npm, and can install any package from the npm registry. This will lay out your node_modules folder using Yarn's resolution algorithm that is compatible with the node.
Description. Workspaces is a generic term that refers to the set of features in the npm cli that provides support to managing multiple packages from your local file system from within a singular top-level, root package.
Yarn Workspaces is a feature that allows users to install dependencies from multiple package. json files in subfolders of a single root package. json file, all in one go. Yarn can also create symlinks between Workspaces that depend on each other, and will ensure the consistency and correctness of all directories.
It is recommended to install Yarn through the npm package manager, which comes bundled with Node.js when you install it on your system.
Now that npm v7.0.0 is out, npm supports workspaces
. You can manage multiple packages from within a singular top-level, root package. See more at https://github.blog/2020-10-13-presenting-v7-0-0-of-the-npm-cli/
Your workflows will not get npm v7.0.0 by default unless you install it using npm install -g npm@7
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With