I am trying monorepo and using yarn workspaces to handle the below scenario.
root/
- Package.json
- yarn.lock
- moduleA/
- package.json
- yarn.lock
- moduleB/
- package.json
- yarn.lock
In root package.json we have "workspaces": {packages: [moduleA/, moduleB/]}
We are generating lock file using yarn install command.
We have dockerfiles for both modules ModuleA & ModuleB
We are just copying respective module in their dockerfile, and while exceuting this command yarn install we get this error The lockfile would have been modified by this install, which is explicitly forbidden
This is obivous because when we are generating lock file from local we have both modules present but in while docker build we have only one module present
What we have tried and didn't worked in ModuleA Dockerfile
yarn workspaces moduleA install
yarn install
We read that we can set environment variable YARN_ENABLE_IMMUTABLE_INSTALLS this can be used, but our expectation is that if we have workspaces for respective modules then this might be very common problem then there will be some best way to resolve this issue.
Any help will be appreciated to deal with this.