Fresh Nextjs app generates runtime errors - reactjs

I'm trying to do a fresh install of nextjs on Windows (see command line screenshot) using gitbash and latest nodejs lts version (16.14.2). When running npm run dev everything seems to be in order.
However, after browsing to http://localhost:3000, I receive this:
I looked at Fresh NextJS App throwing errors before any changes but the version in that issue is next 11.1.1 whereas current is 12.1.4. At this point I'm pretty much stuck. =\

Turns out it was an issue with Chrome extensions. I disabled all of them and no longer received the error. One by one I re-enabled all of them but never found the source. =\

Related

This page doesn’t appear to be using React. If this seems wrong, follow the troubleshooting instructions on Microsoft Edge

I created the build of a MERN Stack application using the npm run build command, then I ran this built application on my default browser (Microsoft Edge) using the npm start command. I then installed the react devtools extension for Edge from Chrome. But when I enable react devtools on my react app, it does not activate and I get the message This page doesn’t appear to be using React.
If this seems wrong, follow the troubleshooting instructions. I don't understand why I get this error because my application is entirely designed in react on the frontend side. I don't know if it's because I got the wrong server start command .
You can try the following solution.
In Edge, right click on React devtools, go to Manage extensions, and select "Allow access to file URLs".
Also, it has been reported that a re-installation of react devtools and a restart of browser may help. By the way, react devtools is available in Microsoft Edge Add-ons, so you can just install it in Edge (since you said you installed it from Chrome).
Updating Chrome to last version worked for me.
Chrome version: 109.0.5414.119 (Official Build) (64-bit)
System version: Ubuntu 20.04.2 LTS

Hot reload stopped working after adjusting environment for work requirements

I started a new developer role a few days ago and made some environmental changes to adapt for work. Since then, my hot reload/fast refresh has just stopped working entirely. Changes don't show up even if I refresh the page manually. Only shows changes when I stop the dev server and restart it with 'npm run dev'. The triangle indicator at the bottom right should be active, showing active reload of the window (this no longer shows up consistently either, and if it does the page gets reloaded, but alas the proposed changes aren't visible)
Context:
It has this effect on all NextJS and react applications of mine. Even running a basic project template off the NextJS examples page shows no hot reload working.
I researched this issue and it seems wrong imports (e.g. importing components using lowercase or files in the pages directory being capitalized) can cause this, but I combed through the code and can't spot any issues (of course, I could be missing it but my codebase is over 300 files).
Service workers in the background can cause issues, but I cleared my browser of all of them to be sure and it still doesn't fix it.
I installed ngrok for tunneling for work purposes and docker-compose to handle the work dev. environment.
Made sure I'm using the latest Next version. Even deleted node_modules and ran npm install. Deleted .next and the out folder and still no luck.
Anybody have any ideas or clues to what I should try next? Is it related to the stuff I installed for work? Something related to VS code or WSL2? Seems so puzzling it kind of just happened overnight. Thanks for any insight or advice!
System information
OS: Windows (WSL2 virtualization for VS code)
Browser: Chrome
Version of Next.js: 10.0.3
Version of Node.js: 14.8.0
Deployment: npm run dev for development work; amplify publish for AWS hosting
The problem is with WSL2. I use WSL2 inside VS Code; which is a big performance upgrade in the Linux environment. The problem is WSL2 is actually in a 'virtualization' and thus cannot send information from VS Code AND the browser (localhost:3000) at the same time.
It's a big issue they are working on and there is no fix yet for it. That's why fast refresh doesn't work because localhost is not receiving the changes being made. Either proxy through or revert back to WSL1 https://github.com/microsoft/WSL/issues/4769
Solution provide by OP on question section
Add a .env file or a .env.local file to your root and put this line on it:
WATCHPACK_POLLING=true
Now, restart your server.
Thanks I encounter the same issue with WSL2. I just switch to windows terminal and it works.
If you run Poweshell as administrator and run
wsl.exe -l -v
This will give you th eversion of wsl your distros run on.
I am personally using Ubuntu, and this is the output
Ubuntu Running 2
docker-desktop Stopped 2
docker-desktop-data Stopped 2
To switch to wsl 1,
Run
wsl.exe --set-version Ubuntu 1
and if you wanna switch back,
run,
wsl.exe --set-version Ubuntu 2.
This worked for me.
In my react projects, I just add in my .env file at the root project folder the values
FAST_REFRESH=false
CHOKIDAR_USEPOLLING=true
and it works! enjoy!
The problem is with WSL2. I use WSL2 inside VS Code. But React JS and Next JS projects don't auto-reload. So, add a .env or .env.local (recommended) file to your root and put these lines on it:
WATCHPACK_POLLING=true
CHOKIDAR_USEPOLLING=true
Now, restart your server.

Why is create react app npm start deploying previous version of code?

When running npm start to deploy my code to localhost:3000 the version displayed is a previous version of the code.
I've tried resetting my editor (Visual Studio Code) and Node.js. Tried disable cache in the network inspector of Chrome.
The browser will reload upon a save, however it will not use the correct code. It continues to 'hang' on the previous version.
This is potentially an issue with the create-react-app service worker.
Can you please look for that file, and remove it or comment it out?
Otherwise, it is possible you have an error in your code.

Error: $compile:tplrt: Cannot render page after compiling AngularJS with WebStorm on Windows

I am currently pretty lost where to start searching for the error that I am facing. The same AngularJS project that my colleagues have been working on for quite a while on Macs cannot be compiled correctly on my Windows machine. No idea if windows and mac has anything to do with the error but just in case I am adding this information.
I've checked out the project with SourceTree and opend it with WebStorm.
First npm install then gulp dev in the terminal of WebStorm and my angularJs-project is beeing compiled without any errors. When then the browser windows with //localhost is beeing opened, the page shows shortly the loading anymation and then stays blank.
In the attached screenshot you can see the output of the console. Any ideas?
AngularJS Version: 1.7.2
NPM Version: 5.6.0
Gulp:
CLI version 3.9.1
Local version 3.9.1
What could make the difference that the project is running perfectly on other machines but not on mine?
[Edit]:
I have now reanimated my old macbook, checked out the exact same project with source tree, installed webstorm, ran npm install, then doing this to set up gulp and then running gulp dev: The App runs just fine.
On my Windows Laptop I've started all over, deinstalled WebStorm, deinstalled node.js and did the whole set up as described above. Only difference that I need to install node.js manually on Windows to use npm.... same error as described before.

React Native Expo Timout Error

I'm currently trying to learn react native. I created a project using create-react-native-app. After the project is created, I started npm start on the folder which shows the QR code. I've installed the expo app on my android phone and scanned the code but I'm getting a Uncaught Error: Timed out, no manifest in cache on my expo app and there is no stack trace given.
I've made it work a while ago but somehow its currently not working.
Im using windows 10.
npm 5.6
yarn 1.5.1
What I've done to fix it using Ubuntu was (I created my app using create-react-native-app):
open terminal
execute ifconfig
find network interface (wlp4s0, in my case)
execute export REACT_NATIVE_PACKAGER_HOSTNAME="IP_FOUND_BEFORE"
yarn start
SUCCESS! Finished building JavaScript bundle in 10069ms
Expo only supports the most recent 6 versions, this is because we have to have all the native code for each version on the client and that gets big fast 🙃💣. As of writing this v26 is almost out, that version of the expo client will not support v19 projects. Please make sure that your app is up-to-date by going to the app.json (or exp.json depending on how old your project is 😅) and checking the version number.
Outside of that, I would also recommend you start your project by calling exp start in the root folder of your project 💙
The problem that causes this is having multiple network connections. In my case, I have a virtual network connection which is used by the packager instead of the wifi connection. So basically what's happening is that my phone and my computer uses different connections. I've found a solution here: https://github.com/react-community/create-react-native-app/issues/598

Resources