I am working on an NPM workspace node project. To deploy one of the workspace's packages, I would like to run npm install and obtain a node_modules directory as a subdirectory of that package such that the package becomes self-contained.
Consider the directory structure below:
node_modules
packages
  ├ cloud-app
  │  ├ src
  │  └ package.json
  ├ helpers
  │  ├ src
  │  └ package.json
  ├ business-logic
  │  ├ src
  └  └ package.json
package.json
Just one deduplicated node_modules is excellent for development in a monorepo. But to deploy the cloud-app package, I need the structure to look like this:
packages
  ├ cloud-app
  │  ├ node_modules
  │  ├ src
  │  └ package.json
  ├ helpers
  │  ├ src
  │  └ package.json
  ├ business-logic
  │  ├ src
  └  └ package.json
package.json
Then, I could upload the cloud-app directory as usual without exposing my NPM workspace to the vendor's (incompatible) CD pipeline.
Is this possible at all? What would be the correct command or procedure here?
 
     
    