Security utility that prevents accidental execution of npm lifecycle scripts by failing during preinstall.
npx @tessl/cli install tessl/npm-lavamoat--preinstall-always-fail@2.1.0LavaMoat Preinstall Always Fail is a security utility npm package that prevents accidental execution of npm lifecycle scripts by failing during the preinstall phase. It forces developers to be explicit about script execution by requiring the --ignore-scripts flag, promoting safer package management practices.
npm install @lavamoat/preinstall-always-failAdd to your project's dependencies:
{
"dependencies": {
"@lavamoat/preinstall-always-fail": "^2.1.1"
}
}This package has no programmatic API. It works automatically through npm's package lifecycle system:
# This will fail with an error message
npm install
# This will succeed - scripts are ignored
npm install --ignore-scripts
# This will also succeed
yarn install --ignore-scriptsWhen installation is attempted without --ignore-scripts, the package fails with this message:
Don't run npm lifecycle scripts by default! Create a .yarnrc or .npmrc and set enableScripts: false. Then, whitelist them with @lavamoat/allow-scriptsThis package implements security through npm lifecycle hooks rather than exportable code:
Prevents accidental execution of npm lifecycle scripts by failing during package installation.
{
"scripts": {
"preinstall": "echo \"Don't run npm lifecycle scripts by default! Create a .yarnrc or .npmrc and set enableScripts: false. Then, whitelist them with @lavamoat/allow-scripts\" && exit 1"
}
}Behavior:
npm install or yarn install--ignore-scripts flag is usedProvides a minimal test script that always passes for package validation.
{
"scripts": {
"test": "exit 0"
}
}Behavior:
The package implements a fail-safe security model:
--ignore-scripts to proceed# Step 1: Attempt normal installation (fails)
npm install
# Output: Error message and exit code 1
# Step 2: Install with scripts disabled (succeeds)
npm install --ignore-scripts
# Step 3: Use selective script execution (recommended)
npx @lavamoat/allow-scripts setupRecommended .npmrc configuration:
enable-scripts=falseRecommended .yarnrc.yml configuration:
enableScripts: false{
"dependencies": {
"@lavamoat/preinstall-always-fail": "^2.1.1",
"@lavamoat/allow-scripts": "^3.0.0"
}
}# GitHub Actions example
- name: Install dependencies safely
run: npm install --ignore-scripts
- name: Setup allowed scripts
run: npx @lavamoat/allow-scripts setupWhen scripts are enabled, installation fails with:
--ignore-scripts flag or configure package manager to disable scripts by defaultThis package throws no runtime errors as it provides no programmatic API. All errors occur during package installation phase only.