is-npm
TypeScript icon, indicating that this package has built-in type declarations

6.0.0 • Public • Published

is-npm

Check if your code is running as an npm or yarn script

Install

npm install is-npm

Usage

import {isNpmOrYarn, isNpm, isYarn} from 'is-npm';

console.table({isNpmOrYarn, isNpm, isYarn});
$ node foo.js
# ┌─────────────┬────────┐
# │   (index)   │ Values │
# ├─────────────┼────────┤
# │ isNpmOrYarn │ false  │
# │    isNpm    │ false  │
# │   isYarn    │ false  │
# └─────────────┴────────┘
$ npm run foo
# ┌─────────────┬────────┐
# │   (index)   │ Values │
# ├─────────────┼────────┤
# │ isNpmOrYarn │  true  │
# │    isNpm    │  true  │
# │   isYarn    │ false  │
# └─────────────┴────────┘
$ yarn run foo
# ┌─────────────┬────────┐
# │   (index)   │ Values │
# ├─────────────┼────────┤
# │ isNpmOrYarn │  true  │
# │    isNpm    │ false  │
# │   isYarn    │  true  │
# └─────────────┴────────┘

Related


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 6.0.0
    1,199,740
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 6.0.0
    1,199,740
  • 5.0.0
    2,734,562
  • 4.0.0
    1,059,025
  • 3.0.0
    207,461
  • 2.0.0
    22
  • 1.0.0
    1,302,656

Package Sidebar

Install

npm i is-npm

Weekly Downloads

6,503,466

Version

6.0.0

License

MIT

Unpacked Size

5.04 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus