Skip to content

NextJS Still Requires React with Preact compatibility Plugin #7680

@kenk2

Description

@kenk2

Bug report

For my example project, I am unable to build and run unless I include react and react-dom in my dependencies, even if the build and server doesn't actually use react.

[kenny@kenny-pc first-preact-app]$ yarn build
yarn run v1.16.0
$ next build
The module 'react' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install --save react'
The module 'react-dom' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install --save react-dom'
internal/modules/cjs/loader.js:670
    throw err;
    ^

Error: Cannot find module 'react'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:668:15)
    at Function.Module._load (internal/modules/cjs/loader.js:591:27)
    at Module.require (internal/modules/cjs/loader.js:723:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at Object.<anonymous> (/home/kenny/first-preact-app/node_modules/next/dist/bin/next:25:15)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Describe the bug

The final build/server doesn't use react react-dom, but is needed for the build in or else the errors appear.
A clear and concise description of what the bug is.

To Reproduce

Clone first preact app, remove react and react-dom as dependencies, and then build.

Expected behavior

The build should work as the module aliases state that preact/compat should be aliased for react and react-dom.

System information

  • Manjaro 18.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions