npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.46k stars 3.15k forks source link

[DOCS] Potential missing or hard to find information on using workspaces #4800

Open metawrap-dev opened 2 years ago

metawrap-dev commented 2 years ago

Is there an existing issue for this?

This is a CLI Docs Problem, not another kind of Docs Problem.

Description of Problem

When running npm install using workspaces, common modules are installed in the root. There are some that I don't want this to happen to, but there seems to be no way or no documented way to achieve this.

Is this a feature issue or just not available in the documentation?

Potential Solution

Provide simple and clear instructions in workspace docs on how to exclude modules from being optimised into the root.

Affected URL

No response

metawrap-dev commented 2 years ago

I have located this discussion. https://github.com/npm/rfcs/pull/375 For what I would assume is a common use-case, it's hard to find a simple answer.

metawrap-dev commented 2 years ago

Also this https://github.com/npm/rfcs/issues/287

frank-dspeed commented 2 years ago

the concept is simple you should simply create

/ package.json => referencing the workspace sets inside workspaces but you should never use npm without the -w or -W flags from that dir
/node_modules => shared between all
/packages => contains all packages (source)
/workspaces/workspace_set_1
/workspaces/workspace_set_2