There is no response when starting React, including "npm start" and "npm run start" - node.js

I downloaded (git clone) 2 git repo, one of which is a React project. If I start it with the command npm start or npm run start, the terminal will stop at the last line and nothing happens:
> meetjobs#0.1.0 start
> PORT=3000 node server.js
Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.
listening on 3000...
I used the npm run start-reactapp command to successfully start the React website of the same PC (Win10), but now it only automatically opens the browser window, and shows the "localhost refused to connect" error.
Please tell me what I have overlooked.

Related

npm run client & npm run server not running properly (won't run at the same time)

In the image you can see the scripts I am using, and on the left side is the folders hierarchy.
According to the defined script when I am running npm run watch, it should run server script and client script as well. But it's only running one script server. It never actually runs the client script.
Same thing happens if I put it like npm run client & npm run server in watch script. It runs only client script and never reaches server script.
One more: If I run npm install it doesn't install as defined in the script. Throws error EISDIR (error shown in image).
Please explain why is this happening and how I can fix this.
Thank you
there is a npm package called concurrently, you can install it as dev dependency and use it to run your watch script.
first install concurrently: "npm isntall concurrently --save"
then on your script: "watch": "concurrently "npm run server" "npm run client""
you can now run both server and client from one script.
source: https://www.npmjs.com/package/concurrently
Try running this script:
"watch":"npm-run-all --parallel server client"

"npm ERR!" When running React application or finds npm version

Whenever I try to find my Npm version, it shows me a list of errors which starts with "npm ERR!", and then shows me the npm version. Secondly whenever I run my React Application in VS Code, it shows me the same errors "npm ERR!" and then run the application.

unable to run npm start in the browser and getting error in win 7

I have just started working with reactjs and for that i have already installed nodejs and in the command i have install the npm install create-react-app and after that i have created create-react-app react-newscard. After the creating it when i tried to run it by using npm start , i was getting the following error as shown in the image.So tell me what i am doing wrong and help me solve the problem and start the code.
It is the link of the error which is shown
Here is what you can do.
Check node -v (See if it gives you a version)
Check npm -v (See if it gives you a version)
If you're getting all the versions, it means your node installation is fine
Then:
npm i -g create-react-app
create-react-app react-newscard --scripts-version 1.1.5
(You can skip the part from "--scripts-version 1.1.5")
npm start by default runs your code using port 3000. sometimes port 3000 is occupied so one of two things can happen
Either your terminal will prompt you if the application can be rendered in a different port
Or It closes without intimation
If it is getting closed without intimation here is what you do
(replace the below in line in package.json > scripts)
"start": "set PORT=4200 && react-scripts start",

Nodemon aequivalent to npm run dev

I've just started using the whole javascript and node.js environment. To start an existing project I run three commands
npm install, npm run all and finally npm run dev to start the application in my browser.
Now, whenever I update the code I stop the current running dev via Ctrl+C, press arrow up key to get npm run dev in my terminal again and hit Enter. I believe there is a better way of doing this repetitive task, like Nodemon.
But, what is the aequivalent command for that, so that the updates I make in the code automatically become visible in the browser?
I have three files which do not work with nodeman: package.json, Gruntfile.js, app/index.js. Moreover, I tried nodemon --exec npm run dev which permanently does sth, but does not start my application.
Do you have any suggestions?
Yes, I would look at the --exec flag on nodemon. You could do something like:
nodemon --exec npm run dev
This will run npm run dev every time a source file changes. Read the nodemon NPM page to get a better idea of how to use it.

'grunt watch' won't run from a package.json script on Windows

I am doing a dev run of a small node app on a Windows machine. I have set up grunt-contrib-watch and can run it successfully from the bash command line by typing 'grunt watch'. It works as expected.
However when I run the following script in my package.json file:
"scripts": {
"start": "node app",
"predev": "grunt",
"dev": "start http://localhost:3000 & node-dev app & grunt watch"
}
...and start the app using 'npm run dev' a new browser tab opens successfully and the app runs on port 3000 as expected, however 'grunt watch' does not run. I can open a new bash window and run 'grunt watch' separately and it works successfully. I can also automate opening the browser window and then running 'grunt watch' successfully, but it seems that I cannot start up the server AND run grunt from the same bash window - is this a known issue in Windows?
When chaining different command with & commands are executed one after the other. That mean that in your configuration the & node-dev app & grunt watch commands will be executed only once you close the server.
To execute different command in parallel in my build I use the parallelshell module... I'm not sure how stable it is though but it seems to work for me. There is probably other more suitable solution.
link to the npm page of parallelshell : https://www.npmjs.com/package/parallelshell

Resources