6

I am trying to deploy angular web app on AWS serverless Lambda following the tutorial https://medium.com/better-programming/getting-started-with-serverless-angular-universal-on-aws-lambda-8754bcc4dc19

It was working fine till last week, but started to throw error "Error: Cannot find module '@vendia/serverless-express'" even though there is no mention of '@vendia/serverless-express' anywhere. The generated lambda.js uses'aws-serverless-express'.

Installed '@vendia/serverless-express' through npm, it got added to package.json. Deployed post that, still error is reported.

Steps to reproduce:

  1. Ensure angular version is 7 or less as toolkit doesn't work with higher version
  2. ng new project-name --style css --routing false
  3. cd project-name
  4. ng add @ng-toolkit/[email protected]
  5. npm run build:prod
  6. npm run server
  7. ng add @ng-toolkit/[email protected]
  8. npm i serverless-api-compression
  9. npm run build:serverless:deploy

Let me know in case of any further information required. Thanks in advance!

1 Answer 1

13

aws-serverless-express has rebranded to @vendia/serverless-express. The new path is not yet included in ng-toolkit's serverless-aws.yml file and that is what is causing the issue.

Adding the following in the serverless.yml excludes would solve the issue.

- '!node_modules/@vendia/**'

End result would be something like

package:
  exclude:
   - src/**
   - node_modules/**
   - firebug-lite/**
   - e2e/**
   - coverage/**
   - '!node_modules/@vendia/**'
   - '!node_modules/aws-serverless-express/**'
   - '!node_modules/binary-case/**'
   - '!node_modules/type-is/**'
   - '!node_modules/media-typer/**'
   - '!node_modules/mime-types/**'
   - '!node_modules/mime-db/**'
Sign up to request clarification or add additional context in comments.

1 Comment

Hi, do you know how to set it up now? since there has been more changes since then

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.