Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Next.js 14] Cannot build static next.js app with next.config.js output property #3840

Open
3 tasks done
matamatanot opened this issue Dec 5, 2023 · 4 comments
Open
3 tasks done

Comments

@matamatanot
Copy link

Before opening, please confirm:

JavaScript Framework

Next.js

Amplify APIs

Not applicable

Amplify Categories

Not applicable

Environment information

Local

  System:
    OS: macOS 14.1.2
    CPU: (12) arm64 Apple M2 Pro
    Memory: 4.06 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/.volta/tools/image/node/20.9.0/bin/node
    npm: 10.1.0 - ~/.volta/tools/image/node/20.9.0/bin/npm
  Browsers:
    Chrome: 119.0.6045.199
    Safari: 17.1.2
  npmGlobalPackages:
    corepack: 0.20.0
    npm: 10.1.0

Describe the bug

https://nextjs.org/docs/app/building-your-application/deploying/static-exports#version-history

v14.0.0 | next export has been removed in favor of "output": "export"

I changed next.config.js for the above changes and pushed codes and the build failed.

Error: The "target" property is no longer supported in next.config.js.

I got the above error even though I set output without setting target.
I assume this is due to the amplify adapter setting target.

Expected behavior

No error.

Reproduction steps

  1. Install next.js 14.
  2. update next.config.js  "output": "export".
  3. (maybe not needed) Change build config in web console. Amazon Linux 2023 / Node.js 18 / Next.js latest
  4. build fail.

Code Snippet

const nextConfig = {
  output: 'export',
};

module.exports = nextConfig;

Log output

2023-12-05T11:04:52.009Z [INFO]: ✓ Generating static pages (18/18)
2023-12-05T11:04:54.416Z [INFO]: Finalizing page optimization ...
2023-12-05T11:04:54.418Z [INFO]: Collecting build traces ...
2023-12-05T11:05:02.821Z [INFO]: 
2023-12-05T11:05:02.825Z [INFO]: Route (pages)                                                                       Size     First Load JS
                                 ┌ ○ /                                                                               3.15 kB         301 kB
                                 ├   └ css/9527f07cb9002c6e.css                                                      1.63 kB
                                 ├ ○ /login                                                                          293 B           281 kB
                                 └ ○ /options/[optionId]/conditions                               710 B           301 kB
                                 + First Load JS shared by all                                                       284 kB
                                 ├ chunks/framework-b31dd959a3bdfd87.js                                            45.2 kB
                                 ├ chunks/main-5d0d6ee21df7e9ec.js                                                 37 kB
                                 ├ chunks/pages/_app-4f1b59ce64023ea0.js                                           196 kB
                                 ├ chunks/webpack-b8864f50dd6e41e7.js                                              2.17 kB
                                 └ css/f6c36e6fc4d05c86.css                                                        2.6 kB
2023-12-05T11:05:02.826Z [INFO]: ○  (Static)  prerendered as static content
2023-12-05T11:05:02.879Z [INFO]: Starting SSR Build...
2023-12-05T11:06:25.115Z [ERROR]: Error: Command failed with exit code 1: node_modules/.bin/next build
                                  > Build error occurred
                                  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 loadConfig (/codebuild/output/src816863117/src/NS-app/frontend/grantee/node_modules/next/dist/server/config.js:744:19)

aws-exports.js

No response

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

@matamatanot matamatanot changed the title [Next.js 14] Cannot build next.js app with next.config.js output property. [Next.js 14] Cannot build static next.js app with next.config.js output property Dec 5, 2023
@nadetastic
Copy link
Member

Hi @matamatanot thank you for opening this issue. I’m transferring it over to the Hosting repository for better assistance.

@nadetastic nadetastic transferred this issue from aws-amplify/amplify-js Dec 5, 2023
@saulonunesdev
Copy link

updating the build image worked for me.
#3295 (comment)

@matamatanot
Copy link
Author

matamatanot commented Feb 9, 2024

I changed AWS Linux 2023 and got an error that /usr/bin/aws: No such file or directory. Any idea where it was changed?

./update_amplify_redirections.sh

cat $OUTPUT_FILE
/usr/local/bin/aws amplify update-app --app-id $AWS_APP_ID --custom-rules file://redirections.json

[WARNING]: ./update_amplify_redirections.sh: line 97: /usr/bin/aws: No such file or directory
[ERROR]: !!! Build failed
[ERROR]: !!! Error: Command failed with exit code 127

Edited: simply aws removing /usr/bin/. Success!

@matamatanot
Copy link
Author

matamatanot commented Feb 9, 2024

Even if you use AWS Linux 2023, the build will fail.
Even if the platform value is set to "Web", "platform": "WEB_DYNAMIC" is automatically set.

Error: The "target" property is no longer supported in next.config.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants