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

384
Vistas
pass variable to npm command string (not the script run by npm command)

Is it possible to pass an argument to the npm command string? The info might be somewhere in docs, but brief digging didn't get me any results, moreover, it is probably beneficial to the large audience.

For example, i have a command build:docker in package.json:

   "scripts": {
      "build:docker": "tsc -b && sh dist.sh && docker build -t repo_name/image .",
   },

I want to pass the tag variable to the command string, ex:

"build:docker": "tsc -b && sh dist.sh && docker build -t repo_name/image:$tag ."

and run it as npm run build:docker --tag '1.0'.

Is something like this possible? Thanks!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Yes, you can: For example (for simplicity), for the line:

"build": "tsc --project "

You can start it like so:

npm run build ./src

This will start:

> tsc --project  "./src"

And another solution (I didn't see the point without glasses :) ), more suitable for you is to prefix the name of the parameter with $npm_config_, so your line should look like this:

"build:docker": "tsc -b && sh dist.sh && docker build -t repo_name/image:$npm_config_mytag ."

And then run it as:

npm run build:docker --mytag=1.0

Watch out for =

over 4 years ago · Santiago Trujillo 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