list2shrink
v0.1.1
Published
create a npm-shrinkwrap.json from npm list
Downloads
4
Maintainers
Readme
list2shrink
This is a command line pipe that can be used to automatically generate an npm-shrinkwrap.json file.
Install with npm
Since this is a command line, it should be installed globally:
npm install --global list2shrink
usage
npm list | list2shrink > npm-shrinkwrap.json
You can shinkwrap the versions used in your Node.js project by including a npm-shrinkwrap.json
file next to your package.json
file. For example, if you have your project working when npm list
says this:
However, when you move your project to another location and execute npm install
, you get different versions. For example:
Notice the different versions?
You can force the npm install
to get the same versions by adding this npm-shrinkwrap.json
file in the same directory as your package.json
file:
{
"dependencies": {
"autoprefixer-core": {
"version": "5.2.1",
"from": "[email protected]",
"dependencies": {
"browserslist": {
"version": "0.4.0",
"from": "[email protected]"
},
"caniuse-db": {
"version": "1.0.30000694",
"from": "[email protected]"
},
"num2fraction": {
"version": "1.2.2",
"from": "[email protected]"
},
"postcss": {
"version": "4.1.16",
"from": "[email protected]",
"dependencies": {
"es6-promise": {
"version": "2.3.0",
"from": "[email protected]"
},
"js-base64": {
"version": "2.1.9",
"from": "[email protected]"
},
"source-map": {
"version": "0.4.4",
"from": "[email protected]",
"dependencies": {
"amdefine": {
"version": "1.0.1",
"from": "[email protected]"
}
}
}
}
}
}
}
}
}
The problem is that it's a pain in the neck to make that *.json
file. So, if you've got your project working and you want to shrinkwrap it, you can use this to generate the npm-shrinkwrap.json
file.
Hint: Save your npm list in a file like this:
npm list | NpmList.txt
Later on, you can generate an npm-shrinkwrap.json
file like this:
cat NpmList.txt | list2shrink > npm-shrinkwrap.json