Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@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 913,867 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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.