vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.07k stars 27.01k forks source link

Don't work `npx next build` with `export` #51990

Closed batazor closed 1 year ago

batazor commented 1 year ago

Verify canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 22.5.0: Mon Apr 24 20:51:50 PDT 2023; root:xnu-8796.121.2~5/RELEASE_X86_64
    Binaries:
      Node: 20.2.0
      npm: 9.6.7
      Yarn: 1.22.19
      pnpm: 8.6.1
    Relevant Packages:
      next: 13.4.8-canary.9
      eslint-config-next: 13.4.7
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: export

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true)

Link to the code that reproduces this issue or a replay of the bug

https://github.com/shortlink-org/shortlink/tree/main/ui/nx-monorepo/packages/landing

To Reproduce

npx next build

Describe the Bug

After upgrading to the latest version (I also checked the beta). I get an error:

- info (pwa) Compiling for client (static)...
- info (pwa) Service worker: public/sw.js
- info (pwa)   URL: /sw.js
- info (pwa)   Scope: /
- info (pwa) Compiling for server...
- info (pwa) Compiling for server...
- info Creating an optimized production build  
- info Compiled successfully
- info Linting and checking validity of types  
- info Collecting page data  

> Server Actions are not supported with static export.
npm ERR! Lifecycle script `build` failed with error: 

Expected Behavior

successful build

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

DuCanhGH commented 1 year ago

You just have to turn experimental.serverActions or output: 'export' off and the build error should be gone :)

balazsorban44 commented 1 year ago

Hi, as mentioned above, Server Actions require a server. output: "export" generates a set of static files only, so these two features cannot be combined.

github-actions[bot] commented 1 year ago

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.