Prevent committing lockfiles
- Lockfiles are for apps, not for libraries/packages
- Listing lockfiles in .gitignore is considered a bad approach
- Unstaging only will introduce new problems
- Uses force-del to get rid of lockfiles
- No need to force contributors to use
npm
oryarn
- No need to use 2 extra dot files (
.npmrc
and.yarnrc
) to avoid generating lockfiles - Works on macOS, Linux, and Windows
npm install --save-dev remove-lockfiles
Install husky:
npm install husky --save-dev
Edit package.json
to include this configuration:
{
"scripts": {
"precommit": "remove-lockfiles"
}
}
Looking for alternative to husky
? We can also use remove-lockfiles
with pre-commit.
Install remove-lockfiles
globally:
npm install --global remove-lockfiles
Run the script:
$ remove-lockfiles --help
Usage
$ remove-lockfiles [path|options]
Options
--shrinkwrap Remove `npm-shrinkwrap.json` if found
Examples
$ remove-lockfiles
$ remove-lockfiles ../foo
$ remove-lockfiles --shrinkwrap
$ remove-lockfiles --shrinkwrap ../foo
Returns Promise<Array>
of deleted lockfiles.
Type: Object
Type: string
Default: process.cwd()
Current working directory.
Type: boolean
Default: false
Set to true
to remove npm-shrinkwrap.json
.
- del-nm-cli - Delete
node_modules
and lockfiles - force-del - Force delete files or folders using glob patterns
- has-lockfile - Detect lockfiles in the working directory
MIT © Lufty Wiranda