Socket
Socket
Sign inDemoInstall

force-npm

Package Overview
Dependencies
2
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    force-npm

Force users to use npm instead of yarn.


Version published
Weekly downloads
1
Maintainers
1
Install size
59.6 kB
Created
Weekly downloads
 

Changelog

Source

[0.0.1] - 2019-04-01

Added

Readme

Source

#force-npm

Force users to use npm instead of yarn.

If run from yarn instead of npm, the process will exit with error code 1 and print an error message.

Note: this will not work if used with yarn add --dev --ignore-scripts. Note: This is fork of use-yarn

Install

npm install --save-dev force-npm 
# or
yarn add --dev force-npm 

Use

CLI

For example, in your package.json:

{
  "scripts": {
     "preinstall": "force-npm || ( npm install --save-dev --no-scripts --no-save force-npm && force-npm )"
  }
}

Or if you're on npm >=5 or have npx:

{
  "scripts": {
     "preinstall": "npx force-npm"
  }
}

You may provide a custom message via the -m flag:

{
  "scripts": {
     "preinstall": "npx force-npm -m 'Please use npm!'"
  }
}

Or, you may also provide a custom message read from a file via the -f flag:

{
  "scripts": {
     "preinstall": "npx force-npm -f path/to/customMessage.txt"
  }
}

You may disable force-npm by setting the DISABLE_FORCE_NPM environment variable to true:

{
  "scripts": {
     "preinstall": "DISABLE_FORCE_NPM=true npx force-npm"
  }
}

API

var forceNpm = require('force-npm')

forceNpm()

// or a custom message
forceNpm('You idiot!')

FAQs

Last updated on 01 Apr 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc