An easy way to get npm user details or default values stored by npm.

Usage no npm install needed!

<script type="module">
  import npmConfigInfo from '';



Build Status Coverage Status codecov npm npm

Get the config information stored by npm. This include the stored user details and folder information of the npm structure. Refer to change Logs for latest changes on the current version.


    npm install npm-config-info


const configInfo = require("npm-config-info").getConfigSync();

let config = configInfo.config;
let user =;
let email =;
let npmFolder = configInfo.folders.prefix;

The code could also run asynchronously:

let configInfo;

    .then(conf => {
        configInfo = conf;

Global Store

Please note that the global values could also be obtained by calling getGlobal() from the returned object.

We will attempt to figure out where the npmrc file resides.

A string variable of where the global npmrc file could be found could also be provided in getGlobal e.g.:

const { configInfo, globState } = require("npm-config-info");

let config = configInfo.getConfigSync();
let globalAuthor;


if (configInfo.globalState === globState.Initialized) {
    globalAuthor =;

// OR
if (
    configInfo.globalState !== globState.NotFound &&
    configInfo.globalState !== globState.NotInitialized
) {
    globalAuthor =;

The global variables can also be created by the constructor:

PLEASE NOTE: although the state could be found on the global object (for now and if global has not been initialized or found). The correct state checking should happen through globalState property

const configInfo = require("npm-conif-info").getConfigSync(true);


Please have a look at npm of how the data is usually resolved.


Contributions are welcome. This was a quick project as I required an easy way to access the stored author creditials from javascript.

Change Log

  • Fixed Readme spelling errors.
  • Added a globalState variable to ConfigInfo (we should have done so from the start). For the moment global will still be an object or the value of globalState if no object could be found. String value on global property is preserved for now, but should not be used. For checking use globalState variable. State on "global" will be removed in future.
  • Added an "enum" globaState to both index.js and ConfInfo.js.


  • Fixing intelisense (d.ts) file for the enum globState.