I am fairly new to full-stack, I started learning and making a demo site using node, express, and MongoDB. I was learning through youtube(WebDevSimplified).
i connected my project to my MongoDB using the uri. and was working fine. in the tutorial a new methord was said is:
1.install tool dotenv( npm i --save-dev dotenv ).
2.create a .env file and lode a field-( DATABASE_URL= mongodb://localhost/db )
3.check if the file is in production env.----
if(process.env.NODE_ENV !== 'production') {
require('dotenv').parse()
}
4.for connecting to db use uri as.----
mongoose.connect( process.env.DATABASE_URL, {useNewUrlParser: true})
I am getting an error:
TypeError: Cannot read property 'toString' of undefined
at Object.parse (F:\MVC project\webdevSimplified\node_modules\dotenv\lib\main.js:42:7)
at Object.<anonymous> (F:\MVC project\webdevSimplified\server.js:2:23)
the next step is deploying in Heroku. for that I think I require to get this so please help me...
try
require('dotenv').config()