Skip to content

React 18RC Upgrade not working #32587

@adesugbaa

Description

@adesugbaa

What version of Next.js are you using?

12.0.7

What version of Node.js are you using?

17.2.0

What browser are you using?

Chrome

What operating system are you using?

MacOS Monterey

How are you deploying your application?

Vercel

Describe the Bug

I have an existing application (in production), and wanted to try out the React18 features.

When I upgrade the rear versions using:

yarn add react@rc react-dom@rc

The application refuses to compile/start:

yarn dev                      
yarn run v1.22.17
$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Loaded env from /Users/ayorinde/Dev/Git/Others/jtv.nextjs/.env.local
info  - Using the createRoot API for React
warn  - You are using an unsupported prerelease of 'react-dom' which may cause unexpected or broken application behavior. Continue at your own risk.
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in /Users/ayorinde/Dev/Git/Others/jtv.nextjs/node_modules/react/package.json
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:429:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:683:3)
    at resolveExports (node:internal/modules/cjs/loader:482:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.mod._resolveFilename (/Users/ayorinde/Dev/Git/Others/jtv.nextjs/node_modules/next/dist/build/webpack/require-hook.js:171:28)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at getPackagePath (/Users/ayorinde/Dev/Git/Others/jtv.nextjs/node_modules/next/dist/build/webpack-config.js:601:41)
    at Object.getBaseWebpackConfig [as default] (/Users/ayorinde/Dev/Git/Others/jtv.nextjs/node_modules/next/dist/build/webpack-config.js:617:9) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

How do we opt in to React18, and try out the new features?

Expected Behavior

I expect the application to compile, and start accepting/responding to requests.

To Reproduce

Create a next application, and upgrade to React18 following this link

Metadata

Metadata

Assignees

No one assigned

    Labels

    UpstreamRelated to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions