The upcoming deployment encounters issues specifically with Amplify

I have been attempting to deploy my Next.js app on AWS Amplify, but unfortunately, it keeps failing.
The build process worked flawlessly in my local environment, and I was even successful in deploying it on Vercel.
However, for some reason, it only fails when trying to deploy on Amplify.

To overcome this issue, I managed to deploy by creating a .babelrc file. Nevertheless, I am still seeking a better solution that involves utilizing SWC.

I tried several solutions:

  • rm package-lock.json && rm -rf node_modules
    and then reinstalling using npm install --force
  • Installing @next/swc-linux-x64-gnu and @next/swc-linux-x64-musl as optionalDependencies
  • Setting swcMinify option to false in next.config.js
  • Removing the compiler option from next.config.js

▼ Environment

v16.13.2 x64 linux

package.json

{
  "name": "my-project",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@svgr/webpack": "^6.2.1",
    "clsx": "^1.2.1",
    "framer-motion": "^6.4.3",
    "next": "12.2.2",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-query": "^3.39.1",
    "react-use": "^17.4.0",
    "recoil": "^0.7.4",
    "styled-components": "^5.3.5",
    "twemoji": "^14.0.2"
  },
  "devDependencies": {
    "@types/node": "18.0.3",
    "@types/react": "18.0.15",
    "@types/react-dom": "18.0.6",
    "@types/styled-components": "^5.1.25",
    "eslint": "8.19.0",
    "eslint-config-next": "12.2.2",
    "typescript": "4.7.4"
  }
}

next.config.js

/** @type {import('next').NextConfig} */

const nextConfig = {
  webpack(config) {
    config.module.rules.push({
      test: /\.svg$/,
      use: ['@svgr/webpack'],
    })
    return config
  },
  reactStrictMode: true,
  swcMinify: true,
  compiler: {
    styledComponents: {
      displayName: true,
      ssr: true,
    },
  },
}

module.exports = nextConfig

▼ Error logs

                                                                  # Starting phase: preBuild
                                 # Executing command: nvm use --lts
2022-07-13T23:48:13.094Z [INFO]: Now using node v16.13.2 (npm v8.1.2)
2022-07-13T23:48:13.095Z [INFO]: # Executing command: node -e 'console.log(process.version, process.arch, process.platform)'
2022-07-13T23:48:13.122Z [INFO]: v16.13.2 x64 linux
2022-07-13T23:48:13.125Z [INFO]: # Executing command: npm ci --include=optional
...
Terminating logging...

Answer №2

Perhaps the issue lies with either the SwcMinify or TypeScript plugins.

I encountered the same problem and resolved it by deactivating SwcMinify and making adjustments to the TypeScript plugins within .eslintrc.json.

"plugins": ["@typescript-eslint/eslint-plugin"],
"extends": [
    "eslint:recommended",
    "next/core-web-vitals",
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:@typescript-eslint/recommended",
    "prettier"
],  

Answer №3

Encountering a similar issue, I found that the most effective solution was to completely remove the node_modules directory and then reinstall all dependencies using yarn install.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error: Property cannot be read after page refresh or modification

Upon refreshing or running the project for the first time, I encounter the error: TypeError: Cannot read property 'statements' of undefined This issue is perplexing as the data renders correctly but it appears that the connection is failing. ...

There is a missing index.html file in my nextjs app, which seems to be causing an issue with Netlify

When trying to deploy my website on Netlify, I encountered an issue as the platform required an index.html file. Unfortunately, Nextjs did not generate one for me when I used create-next-app. Does anyone have a solution to this problem? ...

The socket context provider seems to be malfunctioning within the component

One day, I decided to create a new context file called socket.tsx: import React, { createContext } from "react"; import { io, Socket } from "socket.io-client"; const socket = io("http://localhost:3000", { reconnectionDela ...

Error: Unable to access the 'error' property because it is undefined

I have already defined the error, but I am getting an error message stating "TypeError: Cannot read property 'error' of undefined". I am stuck here and would appreciate any ideas on how to move forward. Thank you for your assistance. Error scr ...

Transferring a PDF document to Next.js

I am facing an issue while trying to upload a PDF file (CV) on next js. Everything seems fine according to my expectations, but when I console.log(req.data) it displays [object:object] Please note: When I console.log the data in frontend, it works fi ...

Trigger the scroll into view of a specific component in NextJS when clicking a button that is located in a separate JS file

I recently started working with NextJS and I have my components spread across different JavaScript files. These components are then imported into a single file located in my "pages" folder (index.js). My goal is to be able to click on a button within the h ...

Laravel Rest API and Github Authentication for Next.js login

I am facing an issue with GitHub authentication login. My setup involves using Laravel API for the backend and Next.js for the frontend. The goal is to allow users to log in with their GitHub accounts. I have already installed the Laravel Socialite package ...

Attention: Two children with identical keys were found, ""

In my current project, I am utilizing ReactJS, NextJS 14, Tailwind CSS, and Framer Motion. When working with React, it's essential to assign unique keys to each repeated child component. In my case, this requirement carries over to NextJS as well. To ...

I am having trouble displaying my favicon.ico file on my website, even though I have made sure to set it as public and included

export const metadata: Metadata = { title: "title", description: "description", icons: { icon: "/favicon.ico", }, }; This code snippet is from the globalLayout file located at /app/layout.tsx. In this project, an ...

Issue with React filter function where data is not being displayed when search query is left

I am facing an issue where the data does not show up when the search term is empty. Previously, I used to have this line in my code if (!searchTerm) return data for my old JSON data, and it worked fine. However, now that I'm using Sanity CDN, this lo ...

The StreamingTextResponse feature is malfunctioning in the live environment

When I share my code, it's an API route in Next.js. In development mode, everything works as expected. However, in production, the response appears to be static instead of dynamic. It seems like only one part of the data is being sent. I'm puzzl ...

The code threw an error stating: "Error: Unable to set a new value to the unalterable property 'children' of the object '#<Object>'"

Encountering internal server error in Next.js build with Docker when reloading all routes with getServerSideProps react: "17.0.2" next: "^11.1.2" Local setup and deployment without Docker works fine, but with Docker implementation, reloading pages leads ...

Managing a database update when server actions involve various form types

My UI dashboard contains multiple forms like "edit title" and "edit description", each with just one input element. I am looking to streamline database updates and server actions in next js 14, utilizing useFormState on the front end. While I have achieve ...

Enhancing NextJS/playwrights with the latest nodejs upgrade?

I am facing issues with my Vercel build due to Playwright's outdated Node.js version: Error: Node.js version 12.x is deprecated. Starting from 2022-08-09, builds will fail unless the Node.js Version is set to 16.x in Project Settings. This change wa ...

What is the best method to retrieve the transloadit final link stored on a file's storage server (such as Google Cloud Storage) and bring it back to the component?

Trying to understand how to retrieve the final link stored in Google Storage (starting with "https://storage.googleapis.com/...") within a React component, but finding the documentation unclear. Even after successful file upload, I keep receiving "ASSEMBL ...

Passing multiple parameters in URL for APIs using Next.js

Is there a way to pass multiple parameters and retrieve results from the next.js API? I found the documentation very helpful, you can check it out here /api/posts/[postId].js The above setup works fine, but I want to know if it's possible to pass an ...

Issue with ngfactory.js warning in Angular 6+ when building in production mode, but the development build is running without any

I am encountering an error while trying to build Angular for production. Can someone please provide a solution to this issue? WARNING in ./src/app/userforms/login/login.component.ngfactory.js 149:679-708 "export 'MAT_PROGRESS_BAR_LOCATION' (impo ...

Troubleshooting problem with Next JS, Next Auth, and personalized Okta Widget

I've been working on implementing a custom Okta widget for the sign-in process in my Next.js app. I have an Okta provider set up at /api/auth. When using the widget to log in, I redirect to http://localhost:3000/api/auth/callback/okta to pass necessar ...

The sidebar in tailwind css is not displaying a scrollbar as expected

I'm currently working on a project to create a WhatsApp clone using Tailwind CSS in ReactJS. However, I've encountered an issue with the contacts list where it's not showing the scrollbar and instead overflowing the content, leading to the w ...

Experience Next.js 13 with Chakra UI where you can enjoy Dark Mode without the annoying White Screen Flash or FOUC (flash of unstyled content)

Upon refreshing the page in my Next.js 13 /app folder application using Chakra UI, I notice a few things: A momentary white flash appears before switching to the dark theme. The internationalization and font settings momentarily revert to default before l ...