aws-amplify / aws-amplify/amplify-cli
Lock file is removed from `amplify pull`
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### Amplify CLI Version
12.5.1
### Question
I recently needed to override some project-level config and followed [this documentation](https://docs.amplify.aws/cli/project/override/) in order to do so.
Running `amplify override project` generated a `amplify/backend/package.json` file in order to include dependencies needed to execute the generated `amplify/backend/awscloudformation/overrides.js` file. Our app uses yarn (v3) to manage its own dependencies, but we decided to manage amplify dependencies separately using NPM. So, within `amplify/backend` I ran `npm install` in order to include the needed dependencies which generated `amplify/backend/package-lock.json` and pushed it all up with `amplify push`. No issues there.
However, when I pull using `amplify pull`, it removes the `amplify/backend/package-lock.json` file and it throws this error:
```
✖ There was an error initializing your environment.
🛑 Packaging overrides failed.
Command failed with exit code 1: yarn install
Usage Error: The nearest package directory (/Users//repos/app/amplify/backend) doesn't seem to be part of the project declared in /Users//repos/app.
- If /Users//repos/app isn't intended to be a project, remove any yarn.lock and/or package.json file there.
- If /Users//repos/app is intended to be a project, it might be that you forgot to list amplify/backend in its workspace configuration.
- Finally, if /Users//repos/app is fine and you intend amplify/backend to be treated as a completely separate project (not even a workspace), create an empty yarn.lock file in it.
```
If I try to pull using option 3 (creating an empty yarn.lock file), both the npm lock file AND the yarn lock file are removed and I see the same error. So I'm hoping you can answer the following questions:
1. Why are my `amplify/backend/package-lock.json` and empty `amplify/backend/yarn.lock` files being removed when I pull?
2. What is the recommended approach to running an amplify project using npm within an app that uses yarn (v3)? Should I be adding an empty `yarn.lock` file as yarn suggests or is there some other recommended approach?
Contributor guide
Research direction
Reproduce `amplify pull` with `amplify/backend/package-lock.json` and an empty `amplify/backend/yarn.lock` after `amplify override project` and `amplify push`. Trace the pull and override-packaging entry points that remove these files, then verify the files are preserved and that an app using Yarn v3 can manage its own dependencies while Amplify uses npm.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100