amplify-js icon indicating copy to clipboard operation
amplify-js copied to clipboard

getDnsSuffix Webpack Error On Build

Open steffen-tomm opened this issue 1 year ago • 7 comments

Before opening, please confirm:

JavaScript Framework

Next.js

Amplify APIs

Not applicable

Amplify Version

v6

Amplify Categories

Not applicable

Backend

Other

Environment information

# Put output below this line


Describe the bug

i have the following bug and i have no idea how to solve it. Google doesn't help me anymore. Someone any idea?

The failure is that when i try npm run build

it responsens:

Failed to compile.

./node_modules/@aws-amplify/auth/dist/esm/providers/cognito/apis/signInWithRedirect.mjs + 47 modules Cannot get final name for export 'getDnsSuffix' of ./node_modules/@aws-amplify/core/dist/esm/clients/index.mjs

Build failed because of webpack errors

Expected behavior

it should create the build, but doesn't

Reproduction steps

npm run build

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

import {type ResourcesConfig} from 'aws-amplify';

export const authConfig: ResourcesConfig['Auth'] = {
    Cognito: {
        userPoolId: 'eu-central-1_SSt3fgGcD',
        userPoolClientId: '5sdfs8fsafdsdvdsafsq2gphi5dsfs',
        identityPoolId: 'eu-central-1:023450d4-dfa43-123a-4533-dfsafdssa543,
        allowGuestAccess: true,
    }
};

export const apiConfig: ResourcesConfig['API'] = {
    GraphQL: {
        endpoint: 'https://dsfgafa4ew5w4xdgfd.appsync-api.eu-central-1.amazonaws.com/graphql',
        region: 'eu-central-1', // optional
        defaultAuthMode: 'userPool'
    }
};

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

steffen-tomm avatar Apr 16 '24 16:04 steffen-tomm

Hello, @steffen-tomm 👋. Did you recently upgrade your app from v5 to v6 by chance, or is this a new v6 app? And can you share what's in your package.json file so we can see your dependencies?

cwomack avatar Apr 16 '24 17:04 cwomack

Additionally, can you see if taking the following steps helps resolve the issue?

  • Delete your node_modules folder
  • Delete your package-lock.json file
  • Reinstall dependencies with npm i

cwomack avatar Apr 16 '24 17:04 cwomack

@cwomack i tried that already, good advise so far.

started directly with v6, like in that documentation: https://docs.amplify.aws/nextjs/start/project-setup/create-application/

package.json looks like that:

{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@aws-amplify/adapter-nextjs": "^1.0.28",
    "aws-amplify": "^6.0.28",
    "classnames": "^2.5.1",
    "next": "^14.2.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "@svgr/webpack": "^8.1.0",
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "autoprefixer": "^10.4.19",
    "eslint": "^8.57.0",
    "eslint-config-next": "^14.2.1",
    "postcss": "^8",
    "tailwindcss": "^3.4.3",
    "typescript": "^5"
  }
}

steffen-tomm avatar Apr 16 '24 19:04 steffen-tomm

import {type ResourcesConfig} from 'aws-amplify';

export const authConfig: ResourcesConfig['Auth'] = {
    Cognito: {
        userPoolId: 'eu-central-1_SSt3fgGcD',
        userPoolClientId: '5sdfs8fsafdsdvdsafsq2gphi5dsfs',
        identityPoolId: 'eu-central-1:023450d4-dfa43-123a-4533-dfsafdssa543,
        allowGuestAccess: true,
    }
};

export const apiConfig: ResourcesConfig['API'] = {
    GraphQL: {
        endpoint: 'https://dsfgafa4ew5w4xdgfd.appsync-api.eu-central-1.amazonaws.com/graphql',
        region: 'eu-central-1', // optional
        defaultAuthMode: 'userPool'
    }
};

that's my config. is something wrong here?

steffen-tomm avatar Apr 17 '24 08:04 steffen-tomm

@steffen-tomm, I'm still a little lost as to how to reproduce this issue and get the errors you're seeing. You mentioned starting with the Next.JS getting started guide, but can you share the steps that different from our docs to get to where you're experiencing the build issues? Do you run into this with a fresh Next.JS project with Amplify imported or was this an existing project that you integrated Amplify into? And finally, do you experience this when running it locally as well?

cwomack avatar Apr 17 '24 20:04 cwomack

i started building the project two month ago, but never went through the build process, because i always ran npm run dev without any issues.

steffen-tomm avatar Apr 18 '24 07:04 steffen-tomm

i started the project like that: https://docs.amplify.aws/nextjs/start/project-setup/create-application/ But i do not use a amplify backend. I build my own written aws infrastructure

What can i do to make it work?

Transfer everything to a new instance?

steffen-tomm avatar Apr 18 '24 16:04 steffen-tomm