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

Packaging lambda function failed with the error: tsc: command not found #3377

Closed
5 tasks done
DiegoMcDipster opened this issue Mar 20, 2023 · 4 comments
Closed
5 tasks done
Labels
archived This issue has been locked. bug Something isn't working pending-triage

Comments

@DiegoMcDipster
Copy link

Before opening, please confirm:

  • I have checked to see if my question is addressed in the FAQ.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • 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.

App Id

d39mjfc3kkuapk

AWS Region

eu-central-1

Amplify Hosting feature

Deployments

Describe the bug

I have an existing amplify app for my dev backend. That env works fine.

If I add a new 'test' amplify env using amplify env add. I cannot deploy it because it fails with the error:
Packaging lambda function failed with the error
Command failed with exit code 127: npm run-script amplify:testHostingFn
sh: tsc: command not found
> [email protected] amplify:testHostingFn
> cd amplify/backend/function/testHostingFn && tsc -p ./tsconfig.json && cd -

Expected behavior

The new test environment should be deployed

Reproduction steps

  1. created next app -ts

  2. created repo on code commit

  3. pushed to code commit

  4. initiated amplify

  5. connected branch to amplify hosting

  6. added amplify REST api & lambda express function

  7. amplify push the BE

  8. created app.ts & ts config etc according to https://docs.amplify.aws/cli/function/build-options/

  9. amplify push

  10. git commit and push - to kick off CICD

  11. error during FE build cos of express already being declared as block scoped variable.

    • fix: exclude 'amplify' on main tsConfig.json
  12. git commit and push - to kick off CICD
    *** ALL Good up to now. env is deployed! ***

  13. create test env following the insturctions: https://docs.amplify.aws/cli/teams/overview/#continuous-deployment-and-hosting

    • amplify add env -> test
    • amplify push
    • create git test branch and push
  14. create hosting for test branch in amplify console.
    Build fails: error:
    Packaging lambda function failed with the error
    Command failed with exit code 127: npm run-script amplify:testHostingFn
    sh: tsc: command not found

    [email protected] amplify:testHostingFn
    cd amplify/backend/function/testHostingFn && tsc -p ./tsconfig.json && cd -

Build Settings

No response

Log output

# Put your logs below this line


Additional information

No response

@DiegoMcDipster DiegoMcDipster added bug Something isn't working pending-triage labels Mar 20, 2023
@DiegoMcDipster
Copy link
Author

I thought this may be a NextJs issue so i created a test app following the steps above with create-react-app. And I have the exact same issue. AppId: dtf5rnawhfgkc

@DiegoMcDipster
Copy link
Author

The solution is to compile the js outside the src folder of the lambda function.

Creating the TS lambda's using these instructions solved the problem: aws-amplify/amplify-cli#6398 (comment)

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot added the archived This issue has been locked. label May 22, 2023
@github-actions github-actions bot locked and limited conversation to collaborators May 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked. bug Something isn't working pending-triage
Projects
None yet
Development

No branches or pull requests

1 participant