https://github.com/commenthol/package-lock
(Re-)Build package-lock.json or npm-shrinkwrap.json file from node_modules folder
https://github.com/commenthol/package-lock
Last synced: about 1 year ago
JSON representation
(Re-)Build package-lock.json or npm-shrinkwrap.json file from node_modules folder
- Host: GitHub
- URL: https://github.com/commenthol/package-lock
- Owner: commenthol
- License: unlicense
- Created: 2017-08-14T19:44:54.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-10-18T19:22:45.000Z (over 5 years ago)
- Last Synced: 2025-04-21T15:09:52.046Z (about 1 year ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# package-lock
> (Re-)Build package-lock.json or npm-shrinkwrap.json file from node_modules folder
## `npm@5` Creating `package-lock.json`
Copying `node_modules` folders and trying to install additional packages leads to
a complete removal of all copied packages with `npm@>=5.0`.
A `package.json` file would solve this issue but nonetheless you would need to
create one with all it's dependencies.
Running `package-lock` on the folder which contains `node_modules` creates the
missing `package-lock.json` file and in case the `package.json` is missing, it
will be created as well. With this you are now save to install additional
packages with `npm i ...`
## `npm@4`, `npm@3` Creating `npm-shrinkwrap.json`
For `npm@<=4.x` you can also use this package to create a `npm-shrinkwrap.json`
file for fixing you dependencies. For me running `npm shrink` is mostly a mess
as there is always an `extraneous` dependency showing up (especially after a dedup).
1. Make a fresh install with
```
rimraf node_modules npm-shrinkwrap.json
npm i --production
```
2. Now create the `npm-shrinkwrap.json` file with
```
package-lock -s
```
## Installation
Requires [nodejs](http://nodejs.org/).
```sh
$ npm install -g package-lock
```
## Usage
```sh
$ package-lock
```
```
Usage: package-lock [options]
Options:
-p, --package force appending found packages to `optionalDependencies` in package.json
-r, --resolve replace resolved repository
-s, --shrink write `npm-shrinkwrap.json` instead of `package-lock.json`
-h, --help output usage information
```
## Tests
```sh
$ npm test
```
## License
Unlicense http://unlicense.org