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

192
Visualizações
NPM global package: How to store data?

I am maintaining a global npm package, the package is an CLI

enter image description here

What i want to do is, for example when the user choose 'Iphone 11' option, the next time user run the package again, 'iPhone 11' should be on top, and from that I think I need to save data to do this

Should I doing this by writing using file system module? and where to save that? or is there another way to do this?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

there are few way, i would recommend to store the configuration in a file that has a common format (json, yaml, etc.) in appropriate path, such as $HOME/.my-pkg.json, ~/.my-pkg/conf.json, $HOME/.cache/my-pkg/, etc.

about 4 years ago · Juan Pablo Isaza Relatório

0

I solved this by writing file using fs-extra and save it to __dirname + '/some-file.json'

when I need to read it again, just using require(__dirname + '/some-file.json')

about 4 years ago · Juan Pablo Isaza 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