Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amplify:<function-name> scripts that install devdependencies for build are installing production dependencies due to NODE_ENV=production #11717

Closed
2 tasks done
josefaidt opened this issue Jan 5, 2023 · 1 comment · Fixed by #11718
Labels
bug Something isn't working functions Issues tied to the functions category p2 pending-release Code has been merged but pending release

Comments

@josefaidt
Copy link
Contributor

josefaidt commented Jan 5, 2023

How did you install the Amplify CLI?

pnpm

If applicable, what version of Node.js are you using?

18

Amplify CLI Version

10.6.0

What operating system are you using?

mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

n/a

Describe the bug

When building an Amplify project such as https://github.com/aws-amplify/docs which contain a build step (as described in the documentation), push/publish attempts will fail if that npm script relies on installing devDependencies (e.g. yarn install) to build TypeScript.

This appears to have been caused by https://github.com/aws-amplify/amplify-cli/pull/11509/files#diff-3bc68c769179efb36682df30f333763c03aa2aae3a1d04c80790846419430514R5

To workaround the issue change yarn install to yarn install --production=false in the function's npm script (i.e. amplify:<function-name>)

Expected behavior

  • function's npm scripts allow installing devDependencies without introducing the --production=false flag
  • function's have an improved build setting (allow adding a TypeScript file to the function src/ and build without further configuration)
  • CLI removes automatic dependency install in favor of lifting control to developers
    • Allow developers to specify a distribution directory
    • Allow developers to specify a preferred package manager (also see https://www.npmjs.com/package/preferred-pm)
    • Allow developers to specify a build npm script
    • Allow developers to optionally specify a mock npm script
  • ...etc

related:

Reproduction steps

  1. clone https://github.com/aws-amplify/docs
  2. run amplify init -y
  3. run amplify push -y
  4. observe error
🛑 Packaging lambda function failed with the error 
Command failed with exit code 127: yarn amplify:submissionsLambda
/bin/bash: tsc: command not found
error Command failed with exit code 127.
error Command failed with exit code 127.
yarn run v1.22.19

Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@joekiller
Copy link
Contributor

Yeah production=true is blowing up my typescript builds that follow the conventions laid out in https://docs.amplify.aws/cli/function/build-options/

Specifically we have @types/aws-lambda in the devDependencies and it won't compile the tsc due to this.

@josefaidt josefaidt added the pending-release Code has been merged but pending release label Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working functions Issues tied to the functions category p2 pending-release Code has been merged but pending release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants