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

TypeError with NextJS 13.4 installation due to missing 'serverActions' property in experimental config #16845

Closed
1 of 4 tasks
ruslanguns opened this issue May 7, 2023 · 4 comments · Fixed by #16909
Closed
1 of 4 tasks
Labels
outdated scope: nextjs Issues related to NextJS support for Nx type: bug

Comments

@ruslanguns
Copy link

ruslanguns commented May 7, 2023

Current Behavior

After installing NextJS 13.4, a TypeError is being thrown with the message "Cannot read properties of undefined (reading 'serverActions')" when running the code. This bug was introduced in the PR #16819, which aimed to add support for NextJS 13.4.

The issue appears to be caused by the experimental configuration missing the 'serverActions' property. This error can be found in line 165 of the with-nx.ts file (

_nextConfig.experimental['serverActions'] ? 'experimental' : 'next';
).

Error wouldn't happen if the serverActions is provided

Expected Behavior

A potential solution to this issue is to validate if the 'serverActions' property has been provided in the _nextConfig.experimental object. For example:

_nextConfig.experimental && _nextConfig.experimental['serverActions'] ? 'experimental' : 'next';

This fix should be implemented as soon as possible to ensure the proper functioning of the code.

GitHub Repo

https://github.com/ruslanguns/nx-issue-16845

Steps to Reproduce

  1. Add Next project
  2. Install NextJS >= 13.4
  3. Serve the project

Nx Report

❯ nx report              

 >  NX   Report complete - copy this into the issue template

   Node   : 18.15.0
   OS     : linux x64
   pnpm   : 8.2.0
   Hasher : Native
   
   nx (global)        : 16.1.0
   nx                 : 16.1.1
   @nx/js             : 16.1.1
   @nx/jest           : 16.1.1
   @nx/linter         : 16.1.1
   @nx/workspace      : 16.1.1
   @nx/eslint-plugin  : 16.1.1
   @nx/next           : 16.1.1
   @nx/react          : 16.1.1
   typescript         : 5.0.4

Failure Logs

❯ nx serve demo --verbose

> nx run demo:serve:development


 >  NX   Cannot read properties of undefined (reading 'serverActions')


TypeError: Cannot read properties of undefined (reading 'serverActions')
    at /home/rus/Projects/RG/nx/nx-issue/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]_typ_2ulqouxg5pgxadp6lsg2huryy4/node_modules/@nx/next/plugins/with-nx.js:110:37
    at forNextVersion (/home/rus/Projects/RG/nx/nx-issue/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]_typ_2ulqouxg5pgxadp6lsg2huryy4/node_modules/@nx/next/src/utils/config.js:70:9)
    at withNx (/home/rus/Projects/RG/nx/nx-issue/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]_typ_2ulqouxg5pgxadp6lsg2huryy4/node_modules/@nx/next/plugins/with-nx.js:107:33)
    at /home/rus/Projects/RG/nx/nx-issue/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]_typ_2ulqouxg5pgxadp6lsg2huryy4/node_modules/@nx/next/src/utils/compose-plugins.js:12:40
    at Generator.next (<anonymous>)
    at fulfilled (/home/rus/Projects/RG/nx/nx-issue/node_modules/.pnpm/[email protected]/node_modules/tslib/tslib.js:164:62)

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

This comment could be useful for reference when the bug has been introduced: #16819 (review)

@jonsoku-dev
Copy link

same issue

@malord
Copy link

malord commented May 9, 2023

For anyone else reaching this page from search, temporary solution is to add experimental: {} to next.config.js:

/**
 * @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
 */
const nextConfig = {
  nx: {
    // Set this to true if you would like to use SVGR
    // See: https://github.com/gregberge/svgr
    svgr: false,
  },

  experimental: {}, // <-- add this
};

@jaysoo
Copy link
Member

jaysoo commented May 10, 2023

We'll patch this. For now use @malord 's workaround.

PR is open now #16909

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: nextjs Issues related to NextJS support for Nx type: bug
Projects
None yet
5 participants