React: npm start - windows cannot find localhost - node.js

I am trying to follow tutorials for basic react-build-app.
ENVIRONMENT
I am using Ubuntu on Windows 10.
Node version: v13.3.0
NPM version: 6.13.1
So far I did,
npm install -g create-react-app
create-react-app calculator
cd calculator
npm start
PROBLEM
When I run npm start, I get pop up dialog from windows saying, Windows cannot find '\https://localhost:3000/\'. Make sure you typed the name correctly, and then try again.
Here is a screenshot of the error
However, in the cli, I see
Local: http://localhost:3000/
On Your Network: http://192.168.56.1:3000/
Note that the development build is not optimized.
To create a production build, use npm run build.```
But when I open my browser and go to http://localhost:3000/, I only see a blank page, and not the normal React logo.
EXPECTED OUTPUT
I should see the react logo when going to http://localhost:3000/, and not receive and error.
ATTEMPTS
Updated nodejs and npm.
Changed ports using package.json. Also tried
using .env file to change port. Same error.
Uninstalled and re-installed ubuntu 18.04 LTS and used NVM to install nodejs and npm.
WORKAROUND
I got tired of fixing error after error with linux, so I just set up npm and nodejs on windows instead. ran create-react-app on windows cli and it worked the first time. Told me something else was listening on the port i was trying to open, so prompted me to change port. I said yes. Now I get the landing page I was looking for.
I am very new at this and have been trying to figure this out for a couple days now, I would appreciate any advice. Thank you.

This is a WSL specific issue with one of the dependencies of react-scripts, more specifically open version 7.0.0.
To resolve, you can:
switch to react-scripts 3.2.0 in your package.json, or
run npm start from something else than WSL (e.g. Powershell), or
wait for open and react to fix the issue
Bug report in React Scripts:
https://github.com/facebook/create-react-app/issues/8081
And the corresponding bug report in open:
https://github.com/sindresorhus/open/issues/154

According to this post in the bug report in open the culprit is lines 76 & 77 of index.js in node_modules/open. If you comment them out then it works fine.
Link to comment:
https://github.com/sindresorhus/open/issues/154#issuecomment-562509596

Related

Strapi: Warning an error occurred while requesting the API

I've been struggling for hours trying to install Strapi on my Ubuntu server.
Ubuntu: 20.04
nodejs: v14.19.0
npm: 6.14.16
strapi: 4
npx create-strapi-app#latest my-project --quickinstall
All the installation process goes seamlessly but when I go to http://mydomain:1337/admin in order to create a first user I get this warning:
an error occurred while requesting the API.
I know this problem has been encountered several times but none of the suggested solutions have helped me so far.
I also found this error in the Chrome console but I'm not not sure it's related to the my problem:
main.815f1087.js:2 Refused to connect to
'http://localhost:1337/admin/project-type' because it violates the
following Content Security Policy directive: "connect-src 'self'
https:".
Any idea ?
You need to build the app. Read this github issue
Run: npm run build or yarn build or strapi build depending on what you are using
First Build your Application by using npm run build then run npm start.
If you are running strapi CMS on docker, and using docker composer to build, then maintain the default port 1337 when binding the container port to your system port.
Do this: -1337:1337
Not this: -8000:13337
I had this error after upgrading to latest Strapi and all dependencies, what helped me, is to rebuild the Strapi admin interface:
yarn build
or
npm run build
then start develop
yarn develop
or
npm run develop
Got the same problem, a simple restart of the server did it for me.
First of all, need to Build the admin panel and then Start the application.
To build the admin panel,
npm run build
# or
yarn build
To start the application with auto-reload,
npm run develop
# or
yarn develop
when you change the port of your strapi app, you must run npm run build or yarn build or strapi build. because strapi admin templates use default port 1337 and for using on another port you must build the project again.
What I did is to change the host address from 0.0.0.0 to 127.0.0.1 in server.js and then ran npm run build and that fixed my issue. I know it sounds strange but it worked.
Thanks.

Electron: Unable to open X display - ERROR:browser_main_loop.cc(1400) - The futex facility returned an unexpected error code

I've been trying to run this code that brings up an electron GUI and takes input from the user. I I've used the following commands to run this project in VSCode powershell terminal:
npm install
npm start
I get the following error messages in the terminal afterwards:
Error Message 1
Error Message 2
Error Message 3
I've already checked that I have the most updated packages for nodejs, npm, electron, electron-packager and electron-builder. You can see the last three in my package.json file under the devDependencies.
Package.json dev dependencies and scripts
I don't really understand what the error is saying here. From the googling I've done, it seems like this happens on WSL when you're trying to launch an electron application but I'm working off of my local machine on Windows, so I wouldn't think that a GUI should throw an error.
I can run main.js by using electron.cmd main.js but this just brings up the GUI splash from electron but the code itself doesn't seem to be executing.
The answer in my case was switching to use Yarn instead of npm. Clearing the node modules folder and running yarn install and running election ./app from the main project folder.

Node cli on Msysgit on WIndows 10

I recently decided to pick up Node on my personal laptop, which I upgraded to Windows 10, and the Node cli seems to hang when I try to run it.
Simply typing node on the console will not initiate the interface, and to do anything else I need to Ctrl+C out of it.
Additionally, running some npm commands take longer than they used to on my laptop. More noticeably, npm init seems to hang after confirming the information to be written to package.json.
Node version is 4.0.0
npm version is 2.14.2
Are there any known issues with Node and npm on Windows 10?
Edit:
After some troubleshooting, I've figured out the error only happens on Msysgit. Neither of the issues happen on the standard command prompt of Windows.
I had the same issue on Windows 7 with Node version 6.11.0 and Msysgit's MINGW64 terminal window.
The problem was caused by the an alias provided by Msysgit as demonstrated below:
$ alias node
alias node='winpty node.exe'
The solution is to run the command:
$ unalias node
Then node will run correctly.
You can add the unalias node command into your .bashrc file in your HOME directory to make this permanent.
Good luck!
Jeff

Errors installing socket.io for node.js

I installed node on my windows 8 machine with no problems and then went to install the socket.io package to use for an assignment. After typing
npm install socket.io
I got a huge amount of errors.
What I've tried so far:
this - nodejs npm install socket.io error
and this - NPM - Can't install socket.IO
The first answer in both.
A lot of the other stuff I'm finding is for either windows 7 or Mac so I'm not sure if this is just a windows 8 thing.
As you can see in logs you have a permission error. Script doesn't have enough permissions to create directory in C:\\Program_Files\.... Use other directory instead or run command with Admin permissions.
Try running
npm install socket.io
except this time run the command line as an administrator. You can do this in Windows 8 by going to your app search, typing cmd, right-clicking then click 'Run as administrator'.
I feel this is the issue because your error message says 'Please try running this command again as root/Administrator'.

Testing Hubot locally in Ubuntu

Hi Stackoverflow community,
Well the thing is that I'm working on a script for hubot. Before starting to code I'm trying to test some hubot commands in the command line (I already did it in Windows but for some reasons I've to change to Ubuntu environment to start to code this brand new custom hubot) I'd like to be able to write in the terminal >Hubot PING and get a response PONG to start to work.
Till now I've already installed Node.js through nodenv https://github.com/OiNutter/nodenv and I tested my node >node -v, got v0.10.22. I forked my hubot and cloned locally and then apply ~./hubot> npm install to get all the dependencies and everything seems OK. Then I went to the installation folder >cd node_modules/hosted-hubot which has a folder called bin, inside the hubot folder.
So, till this point everything seemed OK and I tried to do in the command line: ./bin/hubot and I'm not able to run hubot locally, it gave me: nodenv: version `v0.8' is not installed. I tried to install an older version of node 0.8 and got the same message.
So that's it, hope you guys can help me to try to test my hubot locally
Thanks in advance!!!
I made a fresh install and I instal node.js without nodenv and everything works properly. It may not be the better solution but it was what I did.

Resources