npm does not really reflect how yarn works with regards to workspaces.
Yarn expects you to explicitly install deps, npm does not.
(actually running npm install at any other level than the workspace root might and will break things when using npms workspace implementation)
So to add a package (at root or not) you should manually edit the package.json at the level where you want to add the dependency and then run npm install.
Example:
- You want to add concurrently to your root folder and use it to run multiple scripts... concurrently
- You do not add it to a workspace within the workspace, since it does not actually belong in any of them
- Manually edit package.json in your workspace root folder
- Add
"devDependencies": {
"concurrently": "^5.3.0"
},
- run npm install in your workspace root
- concurrently is now in node_modules and can be executed in your workspace root