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

Preact example doesn't start or build #9057

Closed
rafaelalmeidatk opened this issue Oct 12, 2019 · 1 comment · Fixed by #9079
Closed

Preact example doesn't start or build #9057

rafaelalmeidatk opened this issue Oct 12, 2019 · 1 comment · Fixed by #9079
Labels
good first issue Easy to fix issues, good for newcomers
Milestone

Comments

@rafaelalmeidatk
Copy link
Contributor

rafaelalmeidatk commented Oct 12, 2019

Examples bug report

Example name

using-preact

Describe the bug

When trying to run yarn dev the example breaks with the error:

$ node server.js
/home/rafael/projects/next.js/examples/using-preact/node_modules/next/dist/next-server/lib/amp-context.js:11
exports.AmpStateContext = React.createContext({});
                                ^

TypeError: React.createContext is not a function
    at Object.<anonymous> (/home/rafael/projects/next.js/examples/using-preact/node_modules/next/dist/next-server/lib/amp-context.js:11:33)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/rafael/projects/next.js/examples/using-preact/node_modules/next/dist/next-server/lib/head.js:8:23)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
error Command failed with exit code 1.

To Reproduce

  1. Go to examples/using-preact
  2. Run yarn install && yarn dev
  3. See error

Expected behavior

The app should start successfully

System information

  • OS: Ubuntu 19.04
  • Version of Next.js: 9.1.1

Additional context

createContext is already built-in on the latest version of Preact (Preact X), it could be as simple as updating it, but then comes the second problem: you cannot run yarn build without react and react-dom installed in the project:

$ 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:638
    throw err;
    ^

Error: Cannot find module 'react'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/rafael/projects/next.js/examples/using-preact/node_modules/next/dist/bin/next:29:13)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
error Command failed with exit code 1.

Does the project need to have react and react-dom installed to be built, even if it is already using Preact, or is there a way to alias these modules to the build step like we do in next.config.js?

@timneutkens timneutkens added good first issue Easy to fix issues, good for newcomers help wanted labels Oct 13, 2019
@Timer Timer added this to the 9.1.2 milestone Oct 16, 2019
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Easy to fix issues, good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants