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.
The 'only-allow' npm package is used to enforce the use of a specific package manager in a project. This ensures that all contributors use the same package manager, which can help avoid issues related to package-lock files and dependency management.
Enforce npm usage
This feature ensures that npm is the only package manager allowed for the project. If a user tries to install dependencies using a different package manager, the installation will fail.
/* Add this to your package.json file */
{
"scripts": {
"preinstall": "npx only-allow npm"
}
}
Enforce yarn usage
This feature ensures that yarn is the only package manager allowed for the project. If a user tries to install dependencies using a different package manager, the installation will fail.
/* Add this to your package.json file */
{
"scripts": {
"preinstall": "npx only-allow yarn"
}
}
Enforce pnpm usage
This feature ensures that pnpm is the only package manager allowed for the project. If a user tries to install dependencies using a different package manager, the installation will fail.
/* Add this to your package.json file */
{
"scripts": {
"preinstall": "npx only-allow pnpm"
}
}
Force a specific package manager to be used on a project
Add a preinstall
script to your project's package.json
.
If you want to force npm, add:
{
"scripts": {
"preinstall": "npx only-allow npm"
}
}
If you want to force cnpm, add:
{
"scripts": {
"preinstall": "npx only-allow cnpm"
}
}
If you want to force pnpm, add:
{
"scripts": {
"preinstall": "npx only-allow pnpm"
}
}
If you want to force yarn, add:
{
"scripts": {
"preinstall": "npx only-allow yarn"
}
}
If you want to force bun, add:
{
"scripts": {
"preinstall": "npx only-allow bun"
}
}
FAQs
Force a specific package manager to be used on a project
We found that only-allow demonstrated a not healthy version release cadence and project activity because the last version was released 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.