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

Cannot locate handler error message is not sufficient enough #276

Open
nira40seas opened this issue Jul 25, 2022 · 2 comments
Open

Cannot locate handler error message is not sufficient enough #276

nira40seas opened this issue Jul 25, 2022 · 2 comments

Comments

@nira40seas
Copy link

The following error message in typescript.js doesn't reflect the full path but only the filename.

Error: Typescript compilation failed. Please ensure handlers exists with ext .ts or .js
at /home/runner/work/40Seas/40Seas/node_modules/serverless-plugin-typescript/dist/src/typescript.js:71:15

As a result it is hard to know where the problem is, and whether the code is actually looking in the right place.

@individual11
Copy link

I've run into this just recently using namespaces in the handler.ts file. It hates using multiple dots, and I had to put all my functions on the root of the file to get around it.

@alsohi24
Copy link

In my case, the error started when I installed serverless-dynamodb-local. The only modification I made was to the serverless.yml file to resolve the issue. I placed the TypeScript plugin below dynamodb-offline, and then I moved the functions above the custom DynamoDB configuration.

service:
  name: swapi-nestjs

plugins:
  - serverless-offline
  - serverless-dynamodb-local
  - serverless-plugin-typescript
  - serverless-plugin-optimize

provider:
  name: aws
  Runtime: nodejs20.x
  region: us-east-1
  environment:
    USERS_TABLE: UsersTable

functions:
  createUser:
    handler: src/user/interface/create-user.handler.ts
    events:
      - http:
          path: users
          method: post
  getUserById:
    handler: src/user/interface/get-user-by-id.handler
    events:
      - http:
          path: users/{id}
          method: get

custom:
  dynamodb:
    stages:
      - dev
    start:
      port: 8000
      inMemory: true
      migrate: true      

resources:
  Resources:
    UsersTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: ${self:provider.environment.USERS_TABLE}
        AttributeDefinitions:
          - AttributeName: id
            AttributeType: S
        KeySchema:
          - AttributeName: id
            KeyType: HASH
        BillingMode: PAY_PER_REQUEST

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants