apollo-server-integrations / apollo-server-integration-aws-lambda

An integration to use AWS Lambda as a hosting service with Apollo Server
MIT License
46 stars 9 forks source link

Unable to NPM Install due to `Running postinstall script, failed` #72

Closed TylerSustare closed 1 year ago

TylerSustare commented 1 year ago

Following the deploy to lambda guide here, I'm running into issues when trying to install @as-integrations/aws-lambda. This is happening for version 1.2.0, 1.1.0, 1.01 but not for 1.0.0

I'm using PNPM in a mono repo for my serverless project.

node_modules/.pnpm/@as-integrations+aws-lambda@1.2.0_@apollo+server@4.3.0/node_modules/@as-integrations/aws-lambda: Running postinstall script, failed in 3.6s
.../@as-integrations/aws-lambda postinstall$ npm run build
│ > @as-integrations/aws-lambda@1.2.0 build
│ > npx -p typescript tsc --build tsconfig.build.json
│ ../../../../@types+node@17.0.40/node_modules/@types/node/globals.d.ts(72,13): error TS2403: Subsequent variable declarations must have the same ty
└─ Failed in 3.6s at /Users/tyler/go/src/github.com/tylersustare/project/node_modules/.pnpm/@as-integrations+aws-lambda@1.2.0_@apollo+server@4.3.0/node_modules/@as-integrations/aws-lambda
 ELIFECYCLE  Command failed with exit code 1.

It look like the error is trying to run tsc and running into an issue with variable declarations possibly.

my package.json looks like the following

{
  "name": "api",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "sls": "serverless"
  },
  "devDependencies": {
    "@aws-sdk/client-dynamodb": "^3.241.0",
    "@aws-sdk/lib-dynamodb": "^3.241.0",
    "@aws-sdk/smithy-client": "^3.234.0",
    "@aws-sdk/types": "^3.226.0",
    "@jest/types": "^29.3.1",
    "@serverless/typescript": "^3.18.0",
    "@types/aws-lambda": "^8.10.98",
    "@types/node": "^17.0.40",
    "aws-sdk-client-mock": "^2.0.1",
    "aws-sdk-client-mock-jest": "^2.0.1",
    "esbuild": "^0.14.42",
    "eslint": "^8.14.0",
    "jest": "^29.0.0",
    "jest-environment-node": "^29.3.1",
    "serverless": "^3.19.0",
    "serverless-domain-manager": "^6.2.1",
    "serverless-esbuild": "^1.30.0",
    "serverless-offline": "^8.8.0",
    "ts-jest": "^29.0.3",
    "ts-node": "^10.8.1",
    "tsconfig": "workspace:*",
    "tsconfig-paths": "^4.0.0",
    "typescript": "^4.7.3"
  },
  "dependencies": {
    "@as-integrations/aws-lambda": "1.2.0",
    "@apollo/server": "^4.3.0",
    "aws-lambda": "^1.0.7",
    "db": "workspace:*",
    "graphql": "^16.6.0",
    "helpers": "workspace:*",
    "models": "workspace:*",
    "ulid": "^2.3.0"
  }
}

Calling it out explicitly here. This is an issue for me in 1.2.0, 1.1.0 and 1.0.1 but reverting to version 1.0.0 did not have this issue 😄

trevor-scheer commented 1 year ago

Yeah, this is a bad pattern that propagated from a choice I made in a template repo. Thanks for raising the issue, we'll get a patch out for this!

TylerSustare commented 1 year ago

@trevor-scheer A little extra context. It may not matter but my project was using TS.

trevor-scheer commented 1 year ago

@TylerSustare thanks for the context, that's helpful to know. That is surprising, though I'd suppose a race condition in installed dependencies then (making this problem affect even more folks potentially)?

In any case, this should be resolved for everyone in the latest patch 👍