3

I am trying to build my nextjs project but facing below error.

./node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-express/functions/s3ExpressHttpSigningMiddleware.js + 33 modules
Cannot get final name for export 'DEFAULT_MAX_ATTEMPTS' of ./node_modules/.pnpm/@[email protected]/node_modules/@smithy/util-retry/dist-es/index.js


> Build failed because of webpack errors
 ELIFECYCLE  Command failed with exit code 1.

Below is my package.json file where I am import alot of packages. I have tried reseting cache, deleting node_modules folder, deleting pnpm-lock.yaml file and then reinstalling packages but its not working.

Found a solution of on github by adding below line to next.config.js

 experimental: { serverComponentsExternalPackages: [ 'aws-sdk' ] }

but above is also not working.

Below is package.json file.

{
  "name": "drippy_nextjs",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "postinstall": "prisma generate",
    "test": "jest",
    "test:watch": "jest --watch"
  },
  "dependencies": {
    "@auth/prisma-adapter": "^1.0.11",
    "@aws-sdk/client-s3": "^3.624.0",
    "@aws-sdk/s3-presigned-post": "^3.624.0",
    "@aws-sdk/s3-request-presigner": "^3.624.0",
    "@googleapis/content": "^20.0.1",
    "@headlessui/react": "^1.7.18",
    "@heroicons/react": "^2.1.1",
    "@hookform/resolvers": "^3.3.4",
    "@next/bundle-analyzer": "^14.1.3",
    "@next/third-parties": "^14.1.3",
    "@prisma/client": "^5.8.0",
    "@radix-ui/react-accordion": "^1.1.2",
    "@radix-ui/react-aspect-ratio": "^1.0.3",
    "@radix-ui/react-avatar": "^1.0.4",
    "@radix-ui/react-checkbox": "^1.0.4",
    "@radix-ui/react-dialog": "^1.0.5",
    "@radix-ui/react-dropdown-menu": "^2.0.6",
    "@radix-ui/react-label": "^2.0.2",
    "@radix-ui/react-navigation-menu": "^1.1.4",
    "@radix-ui/react-progress": "^1.0.3",
    "@radix-ui/react-radio-group": "^1.1.3",
    "@radix-ui/react-scroll-area": "^1.0.5",
    "@radix-ui/react-select": "^2.0.0",
    "@radix-ui/react-separator": "^1.0.3",
    "@radix-ui/react-slot": "^1.0.2",
    "@radix-ui/react-tabs": "^1.0.4",
    "@radix-ui/react-toast": "^1.1.5",
    "@radix-ui/react-tooltip": "^1.0.7",
    "@smithy/util-retry": "^3.0.3",
    "@t3-oss/env-nextjs": "^0.9.2",
    "@tailwindcss/typography": "^0.5.10",
    "@tanstack/react-query": "^5.17.10",
    "@tanstack/react-table": "^8.11.7",
    "@trpc/client": "11.0.0-next-beta.193",
    "@trpc/next": "11.0.0-next-beta.193",
    "@trpc/react-query": "11.0.0-next-beta.193",
    "@trpc/server": "11.0.0-next-beta.193",
    "@types/crypto-js": "^4.2.2",
    "@types/express": "^4.17.21",
    "@types/heap": "^0.2.34",
    "@upstash/ratelimit": "^1.0.1",
    "@upstash/redis": "^1.28.3",
    "aws-sdk": "^2.1669.0",
    "axios": "^1.6.5",
    "bcrypt": "^5.1.1",
    "class-variance-authority": "^0.7.0",
    "clsx": "^2.1.0",
    "cmdk": "^0.2.0",
    "crypto-js": "^4.2.0",
    "date-fns": "^3.2.0",
    "dotenv": "^16.3.1",
    "embla-carousel-react": "8.0.0-rc19",
    "google-merchant-feed": "^0.1.0",
    "handlebars": "^4.7.8",
    "heap": "^0.2.7",
    "hex-color-to-color-name": "^1.0.2",
    "is-ua-webview": "^1.1.2",
    "keyword-extractor": "^0.0.28",
    "lucide-react": "^0.309.0",
    "next": "14.1.3",
    "next-auth": "^4.24.5",
    "nodemailer": "^6.9.8",
    "razorpay": "^2.9.2",
    "react": "^18",
    "react-beautiful-dnd": "^13.1.1",
    "react-dom": "^18",
    "react-hook-form": "^7.49.3",
    "react-icons": "^5.0.1",
    "react-intersection-observer": "^9.5.3",
    "react-parallax-tilt": "^1.7.212",
    "react-responsive-masonry": "^2.1.7",
    "react-sortable": "^2.0.0",
    "react-sortablejs": "^6.1.4",
    "react-swipeable": "^7.0.1",
    "react-toastify": "^10.0.4",
    "recharts": "^2.10.4",
    "schema-dts": "^1.1.2",
    "scrypt-async": "^2.0.1",
    "shortid": "^2.2.16",
    "slick-carousel": "^1.8.1",
    "superjson": "^2.2.1",
    "tailwind-merge": "^2.2.0",
    "tailwindcss-animate": "^1.0.7",
    "ts-node": "^10.9.2",
    "uuid": "^9.0.1",
    "vaul": "^0.8.0",
    "xlsx": "^0.18.5",
    "zod": "^3.22.4"
  },
  "devDependencies": {
    "@tailwindcss/aspect-ratio": "^0.4.2",
    "@tailwindcss/forms": "^0.5.7",
    "@testing-library/jest-dom": "^6.4.2",
    "@testing-library/react": "^14.2.1",
    "@types/bcrypt": "^5.0.2",
    "@types/jest": "^29.5.12",
    "@types/node": "^20",
    "@types/nodemailer": "^6.4.14",
    "@types/react": "^18",
    "@types/react-beautiful-dnd": "^13.1.8",
    "@types/react-dom": "^18",
    "@types/react-responsive-masonry": "^2.1.3",
    "@types/react-slick": "^0.23.13",
    "@types/shortid": "^0.0.32",
    "@types/uuid": "^9.0.8",
    "autoprefixer": "^10.0.1",
    "eslint": "^8",
    "eslint-config-next": "14.0.4",
    "jest": "^29.7.0",
    "jest-environment-jsdom": "^29.7.0",
    "jest-mock-extended": "^3.0.5",
    "postcss": "^8",
    "prisma": "^5.8.0",
    "tailwindcss": "^3.3.0",
    "typescript": "^5"
  },
  "prisma": {
    "seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
  }
}

1 Answer 1

0

I had the same problem. I solved it by:

Adding the experimental addition to next.config.js

experimental: {serverComponentsExternalPackages: ['@aws-sdk']},

Keep my two aws packages in these versions, it works also with higher packages as far as I tested.

"@aws-sdk/client-s3": "^3.540.0",
"@aws-sdk/s3-request-presigner": "^3.540.0",

And I moved the nextjs version to 14.1.0.

This eventually worked. Despite it being quite a specific solution, it might help if you don't want to upgrade nextjs yet.

Can you try it with next 14.1.0, because with me 14.1.3 didn't work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.