Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

237
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda