Individual package-lock.json for npm workspaces
Asked Answered
A

1

7

I have two packages inside my npm workspace api & cdk. I would like to create an individual package-lock.json inside api & cdk as both of those projects will get deployed individually. Is this currently possible with npm workspaces? What are other alternatives or strategies?

├── api
│    ├── package.json
├── cdk
│   ├── package.json
├── node_modules
├── package.json
├── package-lock.json 
Androcles answered 5/1, 2023 at 6:56 Comment(1)
Kindly have a look on this - #50472257Flexible
E
2

No, a package-lock.json file will not be generated during npm install for workspaces. This is because workspaces allow for mutual dependencies to be shared.

To handle your CI/CD process, you should use the root package-lock.json and package.json files for each workspace.

Personally, I would suggest creating a root builder Dockerfile that installs all the dependencies. Each workspace's Dockerfile can then copy the dependencies from the root builder.

Embolism answered 2/6, 2023 at 19:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.