Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do yarn workspaces work with npm, too?

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?

like image 402
helt Avatar asked Oct 26 '17 06:10

helt


People also ask

Can I have Yarn and npm both?

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.

Does npm have workspaces?

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.

What is the point of Yarn workspaces?

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.

Should I install Yarn with npm?

It is recommended to install Yarn through the npm package manager, which comes bundled with Node.js when you install it on your system.


1 Answers

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.

like image 68
Sahan Amarsha Avatar answered Oct 01 '22 06:10

Sahan Amarsha