Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

234
Visualizações
How do I update the entries in package.json automatically?

I have package.json which is below

{
  "name": "b",
  "version": "1.0.0",
  "description": "",
  "main": ".eslintrc.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

Now, I want to update "name" from b to new-b. How can I do that programmatically? I tried npm config set command, but it does not update package.json file

Please let me know Thank you

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

If you're trying to use the CLI to modify the package properties, you should be able to use the pkg command. Though I seemed to be running into some issues with it on npm 7.5.4.

npm pkg set name new-b

Edit: Whelp turns out that this command was actually added 2 weeks prior to this post, so you'll actually need at least npm version v7.20.0 to correctly run the command.

over 4 years ago · Santiago Trujillo Relatório

0

If you want to use a JavaScript file, you can use the fs module to change the package.json files contents.

For example, you could have a build.js file which asks you which content to change and then uses fs to read the current file and overwrite it. Refer to this Stack Overflow question for help using fs with JSON objects.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda