Is there a pip freeze equivalent for Node and NPM?

node.js, npm

Solution

It appears to be built into NPM versions 6+ via the `package-lock.json` https://docs.npmjs.com/cli/v7/configuring-npm/package-lock-json

Problem

This is idiomatic in Python: ``` pip freeze > requirements.txt pip install -r requirements.txt ``` The first command saves a list of requirements to a file. Then later you can use the command to install the requirements into your environment. Node has `npm install`, but I don't get how to I'm supposed to dump the state of my dependencies to a package.json. I Googled and found this: ``` npm ls | grep -E "^(├|└)─" | cut -d" " -f2 | awk '{FS = "@"; print "\""$1"\"", ":", "\""$2"\""}' ``` but as the author of this pipeline suggests, there's got to be a better way? What am I missing here? I just want to dump my current deps into a package.json. As https://npmjs.org/doc/shrinkwrap.html says, The "package.json" file is still required if you want to use "npm install". I've skimmed the info on `shrinkwrap`, but I'm not seeing how to simply accomplish this task with `shrinkwrap`.

Original source