question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't run the latest preact example successfully

See original GitHub issue

When I run ‘yarn start’ in preact example after installing, I met the following error:

ironman@DT:~/projects/preact$ yarn start
yarn run v1.22.5
$ react-app-rewired start
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.resolve (internal/modules/cjs/helpers.js:33:19)
    at Object.<anonymous> (/home/ironman/projects/preact/node_modules/react-scripts/scripts/start.js:52:31)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789: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:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
error Command failed with exit code 1.

Within the same environment, the example of styled-components and gatsby can work. This issue has tortured me for 1 day, I don’t know how to solve this problem, I look forward to advices. Thanks. BTW, the codesandbox preact example can’t work either.

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯 Continue google

Expected Behavior 🤔

Steps to Reproduce 🕹

Steps:

  1. curl https://codeload.github.com/mui-org/material-ui/tar.gz/next | tar -xz --strip=2 material-ui-next/examples/preact
  2. cd preact
  3. npm install or yarn install
  4. npm run start or yarn start

Context 🔦

Your Environment 🌎

  System:
    OS: Linux 4.19 Ubuntu 20.04.1 LTS (Focal Fossa) [Note: WSL 2 in Windows 10]
  Binaries:
    Node: 10.23.0 - ~/.nvm/versions/node/v10.23.0/bin/node [Note: I have tried using Node v14 or v15 ]
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v10.23.0/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    @emotion/react: latest => 11.1.2 
    @emotion/styled: latest => 11.0.0 
    @material-ui/core: next => 5.0.0-alpha.18 
    @material-ui/styled-engine:  5.0.0-alpha.18 
    @material-ui/styles:  5.0.0-alpha.18 
    @material-ui/system:  5.0.0-alpha.18 
    @material-ui/types:  5.1.0 
    @material-ui/unstyled:  5.0.0-alpha.18 
    @material-ui/utils:  5.0.0-alpha.18 
    @types/react:  17.0.0 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mnajdovacommented, Dec 9, 2020

@onegrit the only solution that worked for me was downgrading the react-script version

diff --git a/examples/preact/package.json b/examples/preact/package.json
index 03dcddbf62..5c60bcdc8a 100644
--- a/examples/preact/package.json
+++ b/examples/preact/package.json
@@ -11,7 +11,7 @@
     "@testing-library/user-event": "latest",
     "preact": "latest",
     "preact-compat": "latest",
-    "react-scripts": "latest"
+    "react-scripts": "^3.4.3"
   },
   "scripts": {
     "start": "react-app-rewired start",

Let me know if this works for you. I know it’s not the ideal solution, but wasn’t able to find anything better.

1reaction
ewldevcommented, Jan 25, 2021

I would like to work on a pull request 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

using-preact example / preact 18 compat in general does not ...
Verify canary release. I verified that the issue exists in the latest Next.js canary release. Provide environment information.
Read more >
Getting Started | Preact: Fast 3kb React alternative with the ...
This guide helps you get up and running to start developing Preact apps, using 3 popular options. If you're new to Preact, we...
Read more >
Getting started with PreactJS — A Step By Step Guide
Last week Jason Miller released Preact-CLI — A command line based tool ... running above mentioned command should create a new directory ...
Read more >
Build a Preact App with Authentication | Okta Developer
Run Your New Preact Application! You should now be able to save your work and run npm start in the root folder and...
Read more >
Preact lifecycle methods not trigger correclty in safari
when changing state of a component and then changing url, the preact component does not unmount · problem is specific to IE and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found