Security News
npm Updates Search Experience with New Objective Sorting Options
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
@antfu/install-pkg
Advanced tools
@antfu/install-pkg is a utility for programmatically installing npm packages. It simplifies the process of adding dependencies to your project by providing a straightforward API to install packages without needing to manually run npm or yarn commands.
Install a single package
This feature allows you to install a single npm package programmatically. In this example, the 'lodash' package is installed, and a message is logged upon successful installation.
const { install } = require('@antfu/install-pkg');
install('lodash').then(() => {
console.log('Lodash installed');
});
Install multiple packages
This feature allows you to install multiple npm packages at once. In this example, both 'express' and 'mongoose' packages are installed, and a message is logged upon successful installation.
const { install } = require('@antfu/install-pkg');
install(['express', 'mongoose']).then(() => {
console.log('Express and Mongoose installed');
});
Specify package version
This feature allows you to specify the version of the package you want to install. In this example, version 17.0.2 of the 'react' package is installed, and a message is logged upon successful installation.
const { install } = require('@antfu/install-pkg');
install('react@17.0.2').then(() => {
console.log('React 17.0.2 installed');
});
Install devDependencies
This feature allows you to install a package as a dev dependency. In this example, the 'typescript' package is installed as a dev dependency, and a message is logged upon successful installation.
const { install } = require('@antfu/install-pkg');
install('typescript', { dev: true }).then(() => {
console.log('TypeScript installed as a dev dependency');
});
npm-install-package is a utility for installing npm packages programmatically. It provides a simple API to install packages and can be used as an alternative to @antfu/install-pkg. However, it may not offer as many features or as clean an API as @antfu/install-pkg.
yarn-install is a utility for programmatically installing packages using Yarn. It is similar to @antfu/install-pkg but specifically designed for Yarn users. It provides a straightforward API for adding dependencies to your project using Yarn.
npmi is a simple utility for installing npm packages programmatically. It offers basic functionality for adding dependencies to your project and can be used as an alternative to @antfu/install-pkg. However, it may lack some of the advanced features provided by @antfu/install-pkg.
Install package programmatically. Detect package managers automatically (npm
, yarn
, bun
and pnpm
).
npm i @antfu/install-pkg
import { installPackage } from '@antfu/install-pkg'
await installPackage('vite', { silent: true })
MIT License © 2021 Anthony Fu
FAQs
Install package programmatically.
The npm package @antfu/install-pkg receives a total of 746,606 weekly downloads. As such, @antfu/install-pkg popularity was classified as popular.
We found that @antfu/install-pkg demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.