Let Me Install It For You! Install NPM dependencies programmatically 🤙
This package is discontinued. Checkout unjs/nypm for a much better alternative!
- Support Yarn and NPM
- Auto package manager detection
- Using Yarn if
yarn.lock - Using NPM if
package-lock.jsonorpackage.json
- Using Yarn if
- Singleton or Class API
- Optional granters
Using yarn:
yarn add lmifyUsing npm:
npm install lmifyInstall one or more packages in rootDir using the preferred package manager.
const { install } = require('lmify') await install('package-name')Set preferred package manager to use. By default, it will be guessed.
const { setPackageManager } = require('lmify') setPackageManager('yarn')Set project root dir. This causes package manager detection to happen on the next install.
const { setRootDir } = require('lmify') setRootDir(proccess.cwd())Add a granter function to ask the user before installing packages.
This function accepts an array of packages to be added and should return Promise<Boolean>.
Without a granter, install immediately adds package.
If multiple granters added, the first response will be used (either deny or allow).
const { addGranter } = require('lmify') addGranter(async packages => { console.log('Installing packages:', packages) return true // Allow })You can choose between using singleton instance or creating a new instance of LMIFY:
const LMIFY = require('lmify') const constumInstance = new LMIFY(options)stdout: Defaults toprocess.stdoutstderr: Defaults toprocess.stderrrootDir: Defaults toprocess.cwd()packageManager: Better if specified orinstallwill throw a warning if no package manager is detected
MIT - Made with 💖 by Nuxt.js team!