Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
How can I use template literals in an .env file?

I want to use JavaScript's Template Literals in an .env file.

Specifically, I am trying to store a JWT public key in the .env file:

PUBLIC_KEY=
`--BEGIN PUBLIC--
AAAAAA
BBBBBB
CCCCCC
--END PUBLIC--`

But when I try to pull it out using process.env.PUBLIC_KEY JS returns an empty string.

I am using gulp to translate TypeScript but the .env is in the root directory and is required at the start of the gulpfile.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I found a bit of a workaround:

You can use \n to define the line breaks

So it looks like:

PUBLIC_KEY="AAA\nBBB\nCCC"

Tested it and its working

about 4 years ago · Juan Pablo Isaza Report

0

Good news. v16.0.0 and greater now supports JavaScript Template Literals.

You can use it like the following:

PUBLIC_KEY=`--BEGIN PUBLIC--
AAAAAA
BBBBBB
CCCCCC
--END PUBLIC--`
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!