title: Using .env file syntax error is showing in Values: nodejs
body: <p>I am trying to implement the nodemailer for contacts form. I have gone through many resources and I got the below code.
  <strong>server.js</strong></p>
  <pre><code>// require('dotenv').config();
  require('dotenv').config({ path: require('./.env') });
  const express = require(&quot;express&quot;);
  const router = express.Router();
  const cors = require(&quot;cors&quot;);
  const nodemailer = require(&quot;nodemailer&quot;);
  
  const app = express();
  app.use(cors());
  app.use(express.json());
  app.use(&quot;/&quot;, router);
  app.listen(5000, () =&gt; console.log(&quot;Server Running&quot;));
  
  const contactEmail = nodemailer.createTransport({
    service: 'gmail',
    auth: {
      user: process.env.USERNAME,
      pass: process.env.PASSWORD,
    },
  });
  
  contactEmail.verify((error) =&gt; {
    if (error) {
      console.log(error);
    } else {
      console.log(&quot;Ready to Send&quot;);
    }
  });
  
  router.post(&quot;/contact&quot;, (req, res) =&gt; {
    const name = req.body.name;
    const email = req.body.email;
    const phonenumber= req.body.phonenumber;
    const address= req.body.address;
    const EmailSubject= req.body.EmailSubject;
    const message = req.body.message; 
    const mail = {
      from: name,
      to: process.env.SEND_TO_EMAIL,
      // subject: &quot;Email from Fans&quot;,
      subject: 'Email From Fans: ' + EmailSubject,
      html: `&lt;p&gt;Name: ${name}&lt;/p&gt;&lt;p&gt;Email: ${email}&lt;/p&gt;&lt;p&gt;Contact No: ${phonenumber}&lt;/p&gt;&lt;p&gt;Address: ${address}&lt;/p&gt;&lt;p&gt;Message: ${message}&lt;/p&gt;`,
    };
    contactEmail.sendMail(mail, (error) =&gt; {
      if (error) {
        res.json({ status: &quot;ERROR&quot; });
      } else {
        res.json({ status: &quot;Thanks for your time. Your message has been sent successfully!&quot; });
      }
    });
  });
  </code></pre>
  <p>In this file, it's clearly mentioned that I am using the dotenv for the environment to take the value from the .env file.
  below is my <strong>.env</strong> file</p>
  <pre><code>USERNAME = example@gmail.com
  PASSWORD = **********
  SEND_TO_EMAIL = example2@gmail.com
  API_HOST = http://localhost:5000/contact
  </code></pre>
  <p>When I am running command <strong>node server</strong>
  then I am getting below error.</p>
  <pre><code>PS E:\project&gt; node server
  E:\project\.env:1
  USERNAME = example@gmail.com
                    ^
  
  SyntaxError: Invalid or unexpected token
      at wrapSafe (internal/modules/cjs/loader.js:1001:16)
      at Module._compile (internal/modules/cjs/loader.js:1049:27)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
      at Module.load (internal/modules/cjs/loader.js:950:32)
      at Function.Module._load (internal/modules/cjs/loader.js:790:14)
      at Module.require (internal/modules/cjs/loader.js:974:19)
      at require (internal/modules/cjs/helpers.js:92:18)
  </code></pre>
  <p>I don't understand what mistakes I have done. Is there any rule to run or access the .env file?
  I followed the two discussion</p>
  <ol>
  <li><a href="https://stackoverflow.com/questions/68126979/cant-access-variables-from-env-file-in-node-js-application">Cant access variables from .env file in node.js application</a></li>
  <li><a href="https://medium.com/the-node-js-collection/making-your-node-js-work-everywhere-with-environment-variables-2da8cdf6e786" rel="nofollow noreferrer">Node.js Everywhere with Environment Variables!</a>
  But still no luck!</li>
  </ol>