sst / open-next

Open source Next.js serverless adapter
https://open-next.js.org
MIT License
3.7k stars 111 forks source link

[BUG] Could not resolve `@aws-sdk/client-sso-oidc` #407

Closed pinarruiz closed 2 months ago

pinarruiz commented 2 months ago

When building open next, it results in this error:

...
Bundling cache assets...
Bundling server function...
✘ [ERROR] Could not resolve "@aws-sdk/client-sso-oidc"

    node_modules/@aws-sdk/token-providers/dist-cjs/index.js:50:79:
      50 │   const { SSOOIDCClient } = await Promise.resolve().then(() => __toESM(require("@aws-sdk/client-sso-oidc")));
         ╵                                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "@aws-sdk/client-sso-oidc" as external to exclude it from the bundle, which
  will remove this error. You can also surround this "require" call with a try/catch block to handle
  this failure at run-time instead of bundle-time.

/home/user/repos/project-front/node_modules/esbuild/lib/main.js:1649
  let error = new Error(text);
              ^

Error: Build failed with 1 error:
node_modules/@aws-sdk/token-providers/dist-cjs/index.js:50:79: ERROR: Could not resolve "@aws-sdk/client-sso-oidc"
    at failureErrorWithLog (/home/user/repos/project-front/node_modules/esbuild/lib/main.js:1649:15)
    at /home/user/repos/project-front/node_modules/esbuild/lib/main.js:1058:25
    at runOnEndCallbacks (/home/user/repos/project-front/node_modules/esbuild/lib/main.js:1484:45)
    at buildResponseToResult (/home/user/repos/project-front/node_modules/esbuild/lib/main.js:1056:7)
    at /home/user/repos/project-front/node_modules/esbuild/lib/main.js:1085:16
    at responseCallbacks.<computed> (/home/user/repos/project-front/node_modules/esbuild/lib/main.js:703:9)
    at handleIncomingPacket (/home/user/repos/project-front/node_modules/esbuild/lib/main.js:762:9)
    at Socket.readFromStdout (/home/user/repos/project-front/node_modules/esbuild/lib/main.js:679:7)
    at Socket.emit (node:events:518:28)
    at addChunk (node:internal/streams/readable:559:12) {
  errors: [Getter/Setter],
  warnings: [Getter/Setter]
}

Node.js v20.12.2
error Command failed with exit code 1.

My node version: 20.12.2

My package.json dependencies:

{
  "packageManager": "yarn@1.22.22",
  "dependencies": {
    "@emotion/react": "^11.11.4",
    "@emotion/styled": "^11.11.5",
    "formik": "^2.4.5",
    "next": "^14.2.1",
    "next-intl": "^3.11.2",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-use": "^17.5.0",
    "yup": "^1.4.0"
  },
  "devDependencies": {
    "@ianvs/prettier-plugin-sort-imports": "^4.2.1",
    "@types/node": "^20.12.7",
    "@types/react": "^18.2.79",
    "@types/react-dom": "^18.2.25",
    "eslint": "^9.0.0",
    "eslint-config-next": "^14.2.1",
    "gulp": "^5.0.0",
    "gulp-merge-json": "^2.2.1",
    "open-next": "2.3.9",
    "prettier": "^3.2.5",
    "serverless": "3.38.0",
    "serverless-add-api-key": "4.2.1",
    "serverless-iam-roles-per-function": "3.2.0",
    "serverless-offline": "13.3.3",
    "serverless-plugin-lambda-insights": "2.0.0",
    "serverless-prune-plugin": "2.0.2",
    "serverless-pseudo-parameters": "2.6.1",
    "serverless-python-requirements": "6.1.0",
    "serverless-s3-sync": "3.3.0",
    "typescript": "^5.4.5"
  }
}

On executing yarn install on the project with clean node_modules and with cleared yarn cache, I get the following warnings:

warning "open-next > @aws-sdk/client-dynamodb > @aws-sdk/credential-provider-node > @aws-sdk/credential-provider-ini@3.567.0" has unmet peer dependency "@aws-sdk/client-sts@^3.567.0".
warning "open-next > @aws-sdk/client-dynamodb > @aws-sdk/credential-provider-node > @aws-sdk/credential-provider-web-identity@3.567.0" has unmet peer dependency "@aws-sdk/client-sts@^3.567.0".
warning "open-next > @aws-sdk/client-dynamodb > @aws-sdk/credential-provider-node > @aws-sdk/credential-provider-sso > @aws-sdk/token-providers@3.567.0" has unmet peer dependency "@aws-sdk/client-sso-oidc@^3.567.0".

All the warnings mentioned above come from changes made on the commit: credential-provider-ini: https://github.com/aws/aws-sdk-js-v3/commit/5ce5600249cc163188e6fa8facf8ec7b8f435793#diff-28efbabf690ae87c39e8de256188f7b9fd15aa1532509b46e32e470fc9a2d863 credential-provider-web-identity: https://github.com/aws/aws-sdk-js-v3/commit/5ce5600249cc163188e6fa8facf8ec7b8f435793#diff-49c28d1cb42fdaaf4abd3d902f98939000a16805f8a3b9e0be564e3df395cde7 credential-provider-sso: https://github.com/aws/aws-sdk-js-v3/commit/5ce5600249cc163188e6fa8facf8ec7b8f435793#diff-4dbb7c9cedcbb7e6e1bd314417ea693bc764e83828d64814fcf3ec398777274a

In this commit all the packages are moving this packages to peerDependency

If more information is needed, please ask for it. I have taken a look for duplicated issues, but could not find any.

EDIT1: Add more info. EDIT2: Add more info again.

conico974 commented 2 months ago

You'll have to install these dependencies manually for the moment ( @aws-sdk/client-sts, @aws-sdk/client-sso-oidc ). I think we should create an issue in the sdk repo https://github.com/aws/aws-sdk-js-v3. This is a breaking change since it will break every single app or lib that bundle the sdk and that don't have auto-install-peers

conico974 commented 2 months ago

For reference https://github.com/aws/aws-sdk-js-v3/issues/6049

conico974 commented 2 months ago

This should be fixed in the aws sdk in version 3.569. Feel free to reopen if you still have the issues.