aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
3.12k stars 579 forks source link

Missing '../endpoint/endpointResolver' on @aws-sdk/client-s3 when deploying to Vercel #6614

Open dwnppoalt opened 6 days ago

dwnppoalt commented 6 days ago

Checkboxes for prior research

Describe the bug

When deploying my project to Vercel, this error raises:

Cannot find module '../endpoint/endpointResolver'
Require stack:
- /var/task/node_modules/@aws-sdk/client-s3/dist-cjs/auth/httpAuthSchemeProvider.js
- /var/task/node_modules/@aws-sdk/client-s3/dist-cjs/index.js
- /var/task/public/scripts/s3.js
- /var/task/app.js
- /var/task/___now_launcher.js
- /var/runtime/index.mjs
Did you forget to add it to "dependencies" in `package.json`?
INIT_REPORT Init Duration: 738.01 ms    Phase: invoke   Status: error   Error Type: Runtime.ExitError

When I run it locally, it works fine.

Regression Issue

SDK version number

@aws-sdk/client-s3@^3.682.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.12.2

Reproduction Steps

N/A.

Observed Behavior

Cannot find module '../endpoint/endpointResolver'
Require stack:
- /var/task/node_modules/@aws-sdk/client-s3/dist-cjs/auth/httpAuthSchemeProvider.js
- /var/task/node_modules/@aws-sdk/client-s3/dist-cjs/index.js
- /var/task/public/scripts/s3.js
- /var/task/app.js
- /var/task/___now_launcher.js
- /var/runtime/index.mjs
Did you forget to add it to "dependencies" in `package.json`?
INIT_REPORT Init Duration: 738.01 ms    Phase: invoke   Status: error   Error Type: Runtime.ExitError

Expected Behavior

It should be imported normally.

Possible Solution

No response

Additional Information/Context

I import it to my s3.js file using:

const { S3Client, PutObjectCommand, GetObjectCommand, DeleteObjectCommand} = require('@aws-sdk/client-s3');
kuhe commented 6 days ago

The file @aws-sdk/client-s3/dist-cjs/endpoint/endpointResolver.js exists in our distributed artifact, which can be verified by the code browser on https://www.npmjs.com/package/@aws-sdk/client-s3?activeTab=code. Did your build or deployment process omit it?

dwnppoalt commented 6 days ago

I don't think its in the build or install process. My project doesn't have a build command, and it only installs the dependencies through

npm install

aBurmeseDev commented 2 days ago

Hi @dwnppoalt - this may be caused by a mismatch in the versions of the AWS SDK installed locally and on Vercel's deployment environment. What does your package.json look like?

One suggestion would be to update @aws-sdk/client-s3 package to the latest version with npm install @aws-sdk/client-s3. Please share your package.json if issue persists.

dwnppoalt commented 2 days ago

@aBurmeseDev I installed the AWS SDK on my local machine using npm install @aws-sdk/client-s3@latest. It installed version 3.682.0, which I used in my Vercel deployment.

This is my package.json:

  "name": "ins-api",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "node app.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "@aws-sdk/client-s3": "^3.682.0",
    "@aws-sdk/s3-request-presigner": "^3.682.0",
    "@aws-sdk/util-endpoints": "^3.679.0",
    "cors": "^2.8.5",
    "dotenv": "^16.4.5",
    "express": "^4.21.1",
    "jsonwebtoken": "^9.0.2",
    "multer": "^1.4.5-lts.1",
    "pg": "^8.13.1",
    "uuid": "^11.0.2"
  }
}