next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Next.js 13 - Error: The "target" property is no longer supported in next.config.js, Even next.config.js does not have the target property

Open Ajmaljalal opened this issue 2 years ago • 4 comments

Verify canary release

  • [X] I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.0.0
      npm: 8.15.1
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.0.0
      eslint-config-next: 13.0.0
      react: 18.2.0
      react-dom: 18.2.0

What browser are you using? (if relevant)

Chrome

How are you deploying your application? (if relevant)

AWS Amplify

Describe the Bug

I upgraded my next.js app to Next.js 13 and pushed the new version to AWS Amplify. The build failed due to this error: The "target" property is no longer supported in next.config.js

Error: The "target" property is no longer supported in next.config.js. See more info here https://nextjs.org/docs/messages/deprecated-target-config at Object.loadConfig [as default (/codebuild/output/src405507991/src/assistian/node_modules/next/dist/server/config.js:97:19)

Here is my next.config.js with no target:

/** @type {import('next').NextConfig} */
module.exports = {
  webpack(config) {
    config.module.rules.push({
      test: /\.svg$/i,
      issuer: /\.[jt]sx?$/,
      use: ['@svgr/webpack'],
    })
    return config
  }
}

Expected Behavior

Next.js app should build successfully on AWs Amplify after upgrading to version 13.

Link to reproduction

NA

To Reproduce

Upgrade a next.js app to Next.js 13 and push to AWS Amplify for hosting.

Ajmaljalal avatar Oct 27 '22 03:10 Ajmaljalal

According to this https://docs.aws.amazon.com/amplify/latest/userguide/server-side-rendering-amplify.html#supported-unsupported-features amplify supports only up to Next v11 .

It seems like amplify is adding the target property to next.config.js which is not supported in v13.

awareness481 avatar Oct 27 '22 07:10 awareness481

I am also running into this error. I had Next.js latest specified in the Amplify Build Settings and am currently unable to build my apps with that. I kept running into the issue with the target property.

After changing my Amplify Build Settings to version 12 (which, I think, is what it would've been using a few days ago under the latest tag), I now run into Cannot find any generated SSR resources to deploy at the deploy stage. I know Amplify does not officially support Next 12, but I was having no issues running builds a few days ago.

Are you still able to build Next.js 12 apps? Have you found any workarounds?

jedwards1230 avatar Oct 27 '22 13:10 jedwards1230

According to this https://docs.aws.amazon.com/amplify/latest/userguide/server-side-rendering-amplify.html#supported-unsupported-features amplify supports only up to Next v11 .

It seems like amplify is adding the target property to next.config.js which is not supported in v13.

Correct, Amplify does not support Next.js13, so the upgrade won't work.

Ajmaljalal avatar Oct 27 '22 17:10 Ajmaljalal

I am also running into this error. I had Next.js latest specified in the Amplify Build Settings and am currently unable to build my apps with that. I kept running into the issue with the target property.

After changing my Amplify Build Settings to version 12 (which, I think, is what it would've been using a few days ago under the latest tag), I now run into Cannot find any generated SSR resources to deploy at the deploy stage. I know Amplify does not officially support Next 12, but I was having no issues running builds a few days ago.

Are you still able to build Next.js 12 apps? Have you found any workarounds?

I moved back to 12 on the package.json file and added latest to the Amplify build settings. If you add anything greater than 11 in there will break the build process I guess. So make sure it is back to latest

Ajmaljalal avatar Oct 27 '22 17:10 Ajmaljalal

Based on this comment https://github.com/vercel/next.js/issues/41932#issuecomment-1293114285 this does not sound like a Next.js bug, so closing. Indeed, Next.js 13 does not support the target option anymore. The recommendation now is to check out the output: "standalone" option instead. https://nextjs.org/docs/advanced-features/output-file-tracing#automatically-copying-traced-files

balazsorban44 avatar Oct 27 '22 21:10 balazsorban44

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

github-actions[bot] avatar Nov 27 '22 00:11 github-actions[bot]