Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!