npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

occams-conf

v3.0.0

Published

A simple config module

Downloads

6

Readme

npm version CircleCI codecov XO code style

Why Occam's Config?

  • Encourages Build Once Run Anywhere Node.js App Containers
  • No opinion of config file name or location
  • Load additional config files to merge properties
  • Load configs from https endpoints

previous versions

first things's first...

$ npm i occams-conf

Usage

load main config via occams settings

const config = require('occams-conf');

console.log(config.yourProp);

load another config merged with main

const config = require('occams-conf');
config.loadConfig({
    name: 'other-config.js',
    path: 'src'
});

console.log(config.yourProp);
console.log(config.otherProp);

load config from https url with loaderConfig

// example loaderConfig:
// {
//     "path": "https://raw.githubusercontent.com/lxghtless/occams-conf/v2.0.1/config.js"
// }
const config = require('occams-conf');

(async () => {
    await config.init();
    console.log(config.resourceUrl);
});

load config from https url with loadConfig method

const config = require('occams-conf');

(async () => {
    await config.loadConfig({
        path: 'https://raw.githubusercontent.com/lxghtless/occams-conf/v2.0.1/config.js'
    });
    console.log(config.resourceUrl);
});

occams-conf settings file (aka locatorConfig)

  • name (config file name) [String]
  • path (config path) [String]

Any of these will work and will resolve the first one found in this order.

occams.conf.json

{
    "name": "config.js",
    "path": "src"
}

occams.conf.js

const conf = {
    name: 'config.js',
    path: 'src'
};

module.exports = conf;

package.json

{
    "occams-conf": {
        "name": "config.js",
        "path": "src"
    }
}

default

  • name: config.js
  • path: $HOME directory if globally installed || cwd

Example config.js

module.exports = {
    port: process.env.TEST_PORT || 8011,
    name: process.env.TEST_NAME || 'starlord',
    resourceUrl: process.env.TEST_URL || 'https://reqres.in/api/mixtapes'
};

Windows Users

If an error resembling the following occurs, please check out the link below it.

PS C:\src\{projectfolder}> npm start

> [email protected] start C:\src\{projectfolder}
> node src/index.js

Error: ENOENT: no such file or directory, lstat 'C:\Users\{username}\AppData\Roaming\npm\node_modules'
    at Object.realpathSync (fs.js:1561:7)
    at Object.<anonymous> (C:\src\{projectfolder}\node_modules\is-installed-globally\index.js:8:29)
    at Module._compile (internal/modules/cjs/loader.js:1139:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
    at Module.load (internal/modules/cjs/loader.js:988:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Module.require (internal/modules/cjs/loader.js:1028:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at isGloballyInstalled (C:\src\{projectfolder}\node_modules\occams-conf\src\util.js:17:10)
    at getLocatorConfigPath (C:\src\{projectfolder}\node_modules\occams-conf\src\util.js:26:6) {
  errno: -4058,
  syscall: 'lstat',
  code: 'ENOENT',
  path: 'C:\\Users\\{username}\\AppData\\Roaming\\npm\\node_modules'
}

https://stackoverflow.com/questions/19874582/change-default-global-installation-directory-for-node-js-modules-in-windows