0.1.0 • Published 2 years ago

@reaxi/node-detect-runtime v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

node-detect-runtime

detects node runtime

useful for cli tools

  • local (node index.js)

    like executing using node filename.js directly

  • local installed (node_modules)

    npm i my-app (installed in the project package.json and local node_modules) npm exec my-app | yarn my-app

  • npx

    npx my-app

  • global

    npm i -g my-app

    my-app

usage:

import { getRuntime } from 'node-detect-runtime';

const { isGlobal } = getRuntime();

response:

{
    isLocalNode: boolean,
    isLocalInstalled:boolean,
    isNpx: boolean,
    isGlobal: boolean,
    dir: string,
    cwd: string,
    name: string,
}