bryantheastronaut / mernCommentBox

A Tutorial on creating a MERN Stack App from the Facebook Comment React Tutorial
https://medium.com/@bryantheastronaut/react-getting-started-the-mern-stack-tutorial-feat-es6-de1a2886be50
248 stars 92 forks source link

Not able to start api server using 'npm run start-dev' command #13

Open ramesh901 opened 7 years ago

ramesh901 commented 7 years ago

I am in the middle section of the tutorial. I created procfile and updated package.json with "“start-dev”: “nf start -p 3000”. When I run the command 'npm run start-dev' I am getting the warning No Env file found and cannot read property 1 of null. I able to run only the react server and not the api server. image

mixelpixel commented 7 years ago

Likewise, unsure of how to resolve this error. I created a blank .env file in the project directory which gives a different warning, but I've no idea what to put in the .env file

adhamkurniawan commented 7 years ago

Hi I got different error in this part. After added an empty .env file I still got this message when run "npm run start-dev": screenshot from 2017-10-04 15-33-56

This is my package.json file: screenshot from 2017-10-04 15-36-01

How can I fix this error?

muscaiu commented 7 years ago

I made it to the end. Pretty good tutorial! Post you dir structure, maybe i can help.

Gero1369 commented 6 years ago

Ok. I've figured out the problem and fixed it. Here is what I did...

The "No ENV file found" warning.

First, I created a file with the name .env that I later added some database info to. That fixed the No ENV warning.

On to the "Cannot read property '1' of null" warning.

I had to dig around a bit on node-foreman and Procfile. I eventually saw that in the Procfile, I also copied the first line, "//Procfile". That turned out to be the problem. There should only be the "web: ..." and "api: ..." commands, so I removed the offending line and ran npm run start-dev again and it worked like it should.

Hope that this helps!

kakodali commented 6 years ago

Thanks Gero for your detailed research,

Just remove //Procfile from Procfile and it should start the dev server, but there will be two warnings that will be caused by Mongoose latest version ~5. This should not be a blocker though.