when i try run npm run start o node server.js i get this error by require('./.env'), before run node server.js i run npm prune && npm install, i'm begginer with node js
module.js:478
throw err;
Error: Cannot find module './*.env'
at Function.Module._resolveFilename (module.js:476:15)
at Function.Module._load (module.js:424:25)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\luis.a.dominguez\Desktop\inovation\code\app-endpoints-service\server.js:3:11)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
You can use dotenv it is easy to use and it can help you get the .env
file with all the variables that are inside. It can be something like:
/yourfile.env
NAME=YOUR_NAME
/index.js
require('dotenv').config({path: 'yourfile.env'}
console.log(process.env.NAME) //YOUR_NAME
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments