mernCommentBox icon indicating copy to clipboard operation
mernCommentBox copied to clipboard

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

Open ramesh901 opened this issue 7 years ago • 5 comments

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

ramesh901 avatar Sep 19 '17 13:09 ramesh901

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

mixelpixel avatar Sep 22 '17 22:09 mixelpixel

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?

adhamkurniawan avatar Oct 04 '17 08:10 adhamkurniawan

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

muscaiu avatar Oct 25 '17 10:10 muscaiu

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!

Gero1369 avatar Apr 13 '18 17:04 Gero1369

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.

kakodali avatar May 04 '18 17:05 kakodali