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

serverless-plugin-typescript not working with serverless-compose #274

Open
vparkov opened this issue Jul 6, 2022 · 0 comments
Open

serverless-plugin-typescript not working with serverless-compose #274

vparkov opened this issue Jul 6, 2022 · 0 comments

Comments

@vparkov
Copy link

vparkov commented Jul 6, 2022

There are 2 issues when using serverless-plugin-typescript in combination with serverless compose:

For context, this is my folder structure:
/api
handler.ts
serverless.yml
package.json
serverless-compose.yml

I have taken it from this minimal repo setup, have removed the react app, and have added typescirpt - https://github.com/serverless/compose-website-example

serverless-compose.yml

services:
  demo-api:
    path: api

package.json

{
  "dependencies": {
    "@serverless-components/website": "^0.1.0",
    "@serverless/compose": "^1.2"
  },
  "devDependencies": {
    "@types/aws-lambda": "^8.10.101",
    "serverless-offline": "^8.8.0",
    "serverless-plugin-optimize": "^4.2.1-rc.1",
    "serverless-plugin-typescript": "^2.1.2"
  }
}

/api/handler.ts

import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';

export const handler = async (event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> => {
  return {
    statusCode: 200,
    body: JSON.stringify({ message: 'success' }),
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Credentials': true,
    },
  }
};

/api/serverless.yml

service: demo-api
frameworkVersion: "3"

plugins:
  - serverless-plugin-typescript
  - serverless-offline

provider:
  name: aws
  runtime: nodejs16.x

functions:
  hello:
    handler: handler.handler
    events:
      - httpApi:
          method: GET
          path: /api/hello

  1. Running sls api:offline for the second time exits with the error below. The first execution is succeeding, as it generates the .build folder within /api.
Compiling with Typescript...
Typescript compiled.
Environment: darwin, node 16.13.1, framework 3.19.0 (local), plugin 6.2.2, SDK 4.3.2
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Error: EEXIST: file already exists, symlink '/***/compose-website-example/fullstack-app/api/node_modules' -> '/***/compose-website-example/fullstack-app/api/.build/node_modules'
Error: 
  1. Running sls deploy is also failing because it is expecting the node_modules folder at the wrong place
Deploying to stage dev
demo-api › waiting
demo-api › deploying
demo-api › Running "serverless deploy --stage dev"
demo-api › Deploying demo-api to stage dev (us-east-1)
demo-api › Compiling with Typescript...
demo-api › Typescript compiled.
demo-api › × Stack demo-api-dev failed to deploy (1s)
demo-api › Environment: darwin, node 16.13.1, framework 3.19.0 (local), plugin 6.2.2, SDK 4.3.2
demo-api › Credentials: Local, "default" profile
demo-api › Docs:        docs.serverless.com
demo-api › Support:     forum.serverless.com
demo-api › Bugs:        github.com/serverless/serverless/issues
demo-api › Error:
demo-api › Error: ENOENT: no such file or directory, stat '/***/compose-website-example/fullstack-app/api/node_modules'

Both sls offline and sls deploy are working fine if I take the serverless-plugin-typescript out

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

1 participant