fix: add dotenv package for environment (#18)

* Added "dotenv" dependency to package.json

Since the project is using .env file for fetching the port, it had no "dotenv" dependency. This creates confusion when "process.env.PORT" doesn't work. I hope this is convenient for beginners 👍

* Update server.js

Added a line to import `dotenv` dependency to server.js.

* Update package-lock.json

I have added the dotenv dependency to package-lock.json file as requested. I hope it's good now
This commit is contained in:
Zaid Ali 2021-01-19 04:37:17 +05:00 committed by GitHub
parent dfe268e836
commit 38d1c3b9f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

5
package-lock.json generated
View File

@ -90,6 +90,11 @@
"ms": "2.0.0" "ms": "2.0.0"
} }
}, },
"dotenv": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
},
"depd": { "depd": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",

View File

@ -8,7 +8,8 @@
}, },
"dependencies": { "dependencies": {
"express": "^5.0.0-alpha.2", "express": "^5.0.0-alpha.2",
"cors": "^2.8.1" "cors": "^2.8.1",
"dotenv": "^8.2.0"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -2,6 +2,7 @@
// where your node app starts // where your node app starts
// init project // init project
require('dotenv').config();
var express = require('express'); var express = require('express');
var app = express(); var app = express();