Question
NPM 7 workspaces - how to install new package in workspace?
If I have a NPM 7 workspace like this:
root
- submodule0
- submodule1
- submodule2
and I navigate to the submodule0 directory and run npm i somepackage
it seems to "break" the workspace by creating a new package-lock.json in the submodule0 directory and installing all the dependencies there. In other words, it just does the old behavior that existed before I created the workspace.
I was hoping for a command similar to lerna where I can install a new package in submodule0 from the root. Something like:
npm i somepackage --scope submodule0
So far, the only workaround I can find is to edit the submodule0 package.json and add the somepackage
manually. Then run npm i
from the root. Obviously this is not ideal because I need to look up the @latest version, navigate to the subdirectory, open the package.json, etc. etc. as opposed to just typing one line in the root.