I installed Nodejs(v 10.16.0 LTS) and then using Windows Powershell I run following commands
npx create-react-app my-app
cd my-app
npm start
The actual problem I am facing is that if PowerShell window is opened in the background, then my code works properly. But when I close PowerShell and reload Browser Tab, the error occurs which say
This site can’t be reached
localhost refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall.
Kindly help me to figure out this issue. Thanks
When you close PowerShell window you terminate your React app as well, it has to stay opened. Running npm start kicks off local server with your app running. If you want to have possibility to have application running with terminal closed you can use libs like https://www.npmjs.com/package/forever, but I do not recommend that- it's easy to forget you have one app instance running already :)
When you run the command npm start, this is the expected behaviour. This command spawns a new npm instance in the directory from where you have executed it and directs it to start a server. The catch here is that the server runs as an attached process with PowerShell, by default and it is bound to terminate once you close the PowerShell window.
To manually detach a process from the terminal, we use an & after the command on a UNIX-based system (Linux, MacOS etc.) something like npm start &.In case of PowerShell, you can make use of a built-in function called Start-Process like this -
Start-Process -NoNewWindow npm start
If you'd like to read more about it, you can refer a blog post here - https://ariefbayu.xyz/run-background-command-in-powershell-8ea86436684e
Related
I cloned the repo https://github.com/Schveitzer/webdriverio-appium-cucumber-boilerplate and tried to run the tests.
I consistently get the following error.
2022-06-16T22:51:13.157Z ERROR #wdio/runner: Error: Failed to create session.
Unable to connect to "http://localhost:4723/", make sure browser driver is running on that address.
If you use services like chromedriver see initialiseServices logs above or in wdio.log file as the service might had problems to start the driver.
Steps:
Clone the repo
Download the latest version of the demo app which Android-NativeDemoApp-0.4.0.apk. The one in the repo does not work.
Update the capabilities.
Yarn Install/Yarn Run
I made some changes. However, was not able to resolve the issue. Any suggestions to resolve the issue?
From the error, it seems that appium server is not running. One reason could be that the repo has an old version of packages and you might have installed the latest version of appium.
One thing you could try is to remove the this line from the config file and try the below.
Start the appium server using the command appium on terminal
Run your tests and see if it works
Otherwise, you have to upgrade all the packages in the repo. but this also means you may have to change something in the code.
Your appium server is likely not running, from package.json I can see that the appium-service that is supposed to get it up is missing. You have two options:
install the #wdio/appium-service package, and appium should run automatically or
start the appium server yourself, either from the terminal with appium -a 127.0.0.1 -p 4723 or launch the appium desktop app
I am running a node.js application in Windows and I want to make it automatically restart if there is an unhandled exception in the code which causes the application to stop.
I have done some research and I found that a combination "Forever" and "Nodemon" can achieve this goal.
I installed both packages globally on my Windows 10 Device.
npm install forever -g
npm install -g nodemon
I tried using the following command to launch my app:
forever start nodemon --exitcrash app.js
However, I get the following error: "nodemon does not exist"
If try just running "nodemon" the application starts which indicates the Nodemon package is installed however, this will not allow the app to restart after a crash.
Am I doing something wrong? Most advice I find online is only relevant to Linux systems.
If you are already using forever, then you can get rid of nodemon. Instead you can use a combination of forever and cluster module. Simply fork the worker in case of exceptions, and it makes your app more scalable too!
If still nodemon is preferable, maybe try installing it globally using the -g flag
Forever and nodemon achieve 2 completely different objectives
nodemon is used to run your application in development mode, where you are frequently changing code, and need to restart the server .It will not restart your application in case of a crash. more about that later
Forever, on the other hand, is for making your application run as a daemon in production. And auto restart if you have uncaught exceptions.
Historically people have used Forever stand alone, or with upstart scripts, running as a linux service one of the most famous being upstart
Current norm is to use PM2
I am in the process of learning Sveltejs and until now I have been using https://svelte.dev/repl/ to go through the tutorial, which has been working perfectly.
However, I wanted to develop and run Sveltejs applications from my machine (MacBook Air M1) - so I downloaded the provided sveltejs file and opened it in VS Code.
I installed the node_modules npm install. Then, I ran npm run dev which doesn't seem to produce an error
Screenshot of the terminal
Nevertheless, when I open http://localhost:5000, I am presented with a blank page, and going on 'Inspect Element' presents me with an empty webpage: Screenshot of localhost:5000
I downloaded this template from https://svelte.dev/repl/ - I did not make any changes to this project yet it still malfunctions.
Any help is appreciated and thank you in advance!
It should be noted that I am new to web development and the node package manager.
The problem on the M1 mac (actually it is probably due to oSX Catalina not the M1 specifically but I haven’t checked on an intel running Catalina) is that port 5000 is in use by command center. This means that svelte can't bind to that port.
To see what ports are active on your mac run the command
lsof -nP +c 15 | grep LISTEN
When you run npm run dev you can set the port to something else that is not in conflict...This is what I ran.
PORT=54321 npm run dev
That should fix it and run for you.
Then you will access it on
http://localhost:54321
When you start your svelte projest you need this command:
npx degit sveltejs/template my-svelte-project
after you go to your project:
cd my-svelte-project
and when you are in this project you run:
npm install
npm run dev
after npm run dev normally you have an information on witch port application runs.
Then you go to src and App.svelte and you remplace code by default by your code.
Normally it has to work.
Did you have a welcome page of svelte before you put your code?
here you have a good tutorial of svelte.
Local Server Auto Refresh of create-react-app is not working in my Virtual Machine: When I update my code, the server is not auto updating.
I'm using Ubuntu as OS and VSCode to write code and the VSCode terminal to run the app locally.
The command to local startup:
npm start
I created an .env and add CHOKIDAR_USEPOLLING=true to it.
Why? This ensures that the next time of run npm start, the watcher uses the polling mode, as necessary inside a VM.
Got this from here:
Development server of create-react-app does not auto refresh
And up the answer.
After finished specified command npm run dev, I can't again write new command in node console.
How can I continue to write from a new line?
Thanks, everybody for the help!
npm run dev in most cases is intended to keep running, detect changes, re-transpile files and (hot) reload the application. That's intended behavior, so don't panic.
You should leave that terminal untouched and simply open a second one if you want to do anything else.
You will have to open another terminal window. The reason is that webpack is now listening for changes - meaning the process in your current terminal window is still running.
Opening another terminal window will allow you to run other commands while the webpack process is still running.
I found the right way. CTRL+C, after need to choose stop or not the execution of processing of listening and then will get a new line.