node.js - Where to store a node_package specific settings on the client machine? -


i' have node_package bookiza (installed globally) posts/patches values receiving substrate using credentials taken off .rc file.

i'm saving .rc file inside module itself, @ usr/lib/node_modules/bookiza, can anywhere like. problem in storing inside package settings overwritten whenever user npm -g installs again, update package.

function updatebookizaconfig(res) {    var bookizaconfig = json.parse(fs.readfilesync(path.join(__dirname, '..', '.bookizarc')).tostring());    bookizaconfig.token = res.body.key;   bookizaconfig.username = res.body.username;   bookizaconfig.email = res.body.email;    fs.writefilesync(path.join(__dirname, '..', '.bookizarc'), json.stringify(bookizaconfig, null, 2));    // move or copy config file outside of package retain credentials upon package update.   // cp('-r', path.join(__dirname, '..', '.bookizarc'), path.join(__dirname, '..', '..'));     console.log(chalk.bold.cyan('registration successful'));  } 

this works, note .dotfile file saved inside usr/lib/node_modules/ directory, sibling other global packages installed on machine. put settings file anywhere else on machine too, practice/standard way of doing this?

will better me put settings file inside usr/lib/node_modules/dots folder in future other package writers put .rc files?

users in comments have hit on solution, here record anyway:

  1. npm recommends save user-specific config data in user's home directory rather in npm's modules directory, both because inconvenient persist settings, , because problem in multi-user environments.

  2. there number of modules find user's home directory in cross-platform way put files in; https://www.npmjs.com/package/osenv


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -