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

162
Vistas
How can I use variables with npm 7.x.x in package.json?

I'd like to access keys in directories using npm script for it.

  "directories": {
    "client": "client",
    "server": "server"
  },
  "scripts": { 
    "test:client": "npm run local-tests --prefix ./$npm_package_directories_client", 
  }

But after updating npm from 6.x.x to 7.5.x I'm not allowed to do that anymore.

How I can do that with the new npm?

Thanks

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

0

I could solve it by moving my variables under "config": {…}.

Like so:

  "config": {
    "directories": {
      "client": "client",
      "server": "server"
    }
  },
  "scripts": { 
    "test:client": "npm run local-tests --prefix ./$npm_package_config_directories_client", 
  }

See https://docs.npmjs.com/cli/v7/configuring-npm/package-json#config

over 4 years ago · Santiago Trujillo Denunciar

0

Same problem! Solved using your solution! Thanks mate! I suggest a nive way to add commentaries to our json files.

  "config": {
     "@comments devPath": "Path to build the develeping code.",
     "devPath": "../castorweb/src/dist/webapps/AQSAPP_TEMPLATE/tmp",
     "@comments prodPath": "Path to build the production code: When generating app versions",
     "prodPath": "../castorweb/src/dist/webapps/AQSAPP_TEMPLATE/dist"
  },
over 4 years ago · Santiago Trujillo Denunciar

0

The solution for this problem is following:

"workspaces": [
   "workspace-a"
]
"scripts": { 
   "test:client": "npm run local-tests -w", 
}

see npm workspaces docs

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