aws-amplify / aws-amplify/amplify-hosting
Amplify deploy fails when using pnpm catalogs
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
### Environment information
```plain text
System:
OS: macOS 15.0.1
CPU: (8) arm64 Apple M1
Memory: 331.17 MB / 16.00 GB
Shell: /bin/zsh
Binaries:
Node: 20.18.1 - ~/.asdf/installs/nodejs/20.18.1/bin/node
Yarn: undefined - undefined
npm: 10.8.2 - ~/.asdf/plugins/nodejs/shims/npm
pnpm: 9.5.0 - ~/.asdf/installs/nodejs/20.18.1/bin/pnpm
NPM Packages:
@aws-amplify/auth-construct: Not Found
@aws-amplify/backend: Not Found
@aws-amplify/backend-auth: Not Found
@aws-amplify/backend-cli: 1.4.2
@aws-amplify/backend-data: Not Found
@aws-amplify/backend-deployer: 1.1.10
@aws-amplify/backend-function: Not Found
@aws-amplify/backend-output-schemas: 1.4.0
@aws-amplify/backend-output-storage: Not Found
@aws-amplify/backend-secret: 1.1.5
@aws-amplify/backend-storage: Not Found
@aws-amplify/cli-core: 1.2.0
@aws-amplify/client-config: 1.5.2
@aws-amplify/deployed-backend-client: 1.4.2
@aws-amplify/form-generator: 1.0.3
@aws-amplify/model-generator: 1.0.9
@aws-amplify/platform-core: 1.2.2
@aws-amplify/plugin-types: 1.5.0
@aws-amplify/sandbox: 1.2.6
@aws-amplify/schema-generator: 1.2.5
aws-amplify: Not Found
aws-cdk: 2.171.1
aws-cdk-lib: 2.171.1
typescript: 5.5.4
No AWS environment variables
No CDK environment variables
```
### Describe the bug
When deploying monorepo using the [pnpm catalogs](https://pnpm.io/catalogs), Amplify cannot figure out the 'next' version.
Minimal reproduces
- https://github.com/hwwi/issue-amplify-turborepo-pnpm-catalogs/tree/main - turborepo + pnpm => deploy success.
- https://github.com/hwwi/issue-amplify-turborepo-pnpm-catalogs/tree/with-catalogs - turborepo + pnpm + pnpm catalogs => deploy fails.
>
> Amplify build log
>
> 2024-12-06T08:43:18.815Z [INFO]: # Cloning repository: git@github.com:hwwi/issue-amplify-turborepo-pnpm-catalogs.git
> 2024-12-06T08:43:20.094Z [INFO]:
> 2024-12-06T08:43:20.095Z [INFO]: Cloning into 'issue-amplify-turborepo-pnpm-catalogs'...
> 2024-12-06T08:43:20.095Z [INFO]: # Switching to commit: 81217aa2cde4b7bfff0d6fe2e4e7c154810f8705
> 2024-12-06T08:43:20.107Z [INFO]: Note: switching to '81217aa2cde4b7bfff0d6fe2e4e7c154810f8705'.
> You are in 'detached HEAD' state. You can look around, make experimental
> changes and commit them, and you can discard any commits you make in this
> state without impacting any branches by switching back to a branch.
> If you want to create a new branch to retain commits you create, you may
> do so (now or later) by using -c with the switch command. Example:
> git switch -c
> Or undo this operation with:
> git switch -
> Turn off this advice by setting config variable advice.detachedHead to false
> HEAD is now at 81217aa feat: apply pnpm catalogs
> 2024-12-06T08:43:20.198Z [INFO]: Successfully cleaned up Git credentials
> 2024-12-06T08:43:20.198Z [INFO]: # Checking for Git submodules at: /codebuild/output/src3269592691/src/issue-amplify-turborepo-pnpm-catalogs/.gitmodules
> 2024-12-06T08:43:20.203Z [ERROR]: !!! CustomerError: Cannot read 'next' version in package.json.
> If you are using monorepo, please ensure that AMPLIFY_MONOREPO_APP_ROOT is set correctly.
> Learn More: https://docs.aws.amazon.com/amplify/latest/userguide/monorepo-configuration.html#setting-monorepo-environment-variable
> 2024-12-06T08:43:20.204Z [INFO]: # Starting environment caching...
> 2024-12-06T08:43:20.204Z [INFO]: # Environment caching completed
>
### Reproduction steps
1. Initialize monorepo with turborepo + pnpm + pnpm catalogs
``` shell
npx create-turbo@latest --example with-tailwind
# ? Where would you like to create your Turborepo? ./issue-amplify-turborepo-pnpm-catalogs
# ? Which package manager do you want to use? pnpm
cd issue-amplify-turborepo-pnpm-catalogs
pnpx codemod pnpm/catalog
echo "\nnode-linker=hoisted" >> .npmrc
```
2. Create amplify.yml
```yaml
version: 1
applications:
- frontend:
phases:
preBuild:
commands:
- npm install -g pnpm
- pnpm install
build:
commands:
- pnpm turbo run build --filter=docs
artifacts:
baseDirectory: apps/docs/.next
files:
- '**/*'
cache:
paths:
- .next/cache/**/*
- node_modules/**/*
buildPath: /
appRoot: apps/docs
- frontend:
phases:
preBuild:
commands:
- npx pnpm install
build:
commands:
- npx turbo run build --filter=web
artifacts:
baseDirectory: apps/web/.next
files:
- '**/*'
cache:
paths:
- .next/cache/**/*
- node_modules/**/*
buildPath: /
appRoot: apps/web
```
3. Deploy with "AMPLIFY_MONOREPO_APP_ROOT" environment variable.
Contributor guide
Assessment
This issue has not been assessed yet.