Looking at package.json
making sense of package-lock.json
- tags
- node
- npm
- packagemanagers
- git
Contents
Look at the dependencies
First lets create a simple project and add a single module, in this
case npm-api which will we use to access the main repository.
| |
And lets see what's been installed in node_modules:
| |
| 68 | |
| 12M | node_modules |
68 directories with 12M of code! Yowza! That's-a big package. Lets
parse up the package-lock.js file to see if it agrees:
| |
| 1 | JSONStream | 1.3.5 |
| 2 | ajv | 6.12.4 |
| 3 | asn1 | 0.2.4 |
| 4 | assert-plus | 1.0.0 |
| 5 | asynckit | 0.4.0 |
| 6 | aws-sign2 | 0.7.0 |
| 7 | aws4 | 1.10.1 |
| 8 | axios | 0.18.1 |
| 9 | bcrypt-pbkdf | 1.0.2 |
| 10 | caseless | 0.12.0 |
| 11 | clone-deep | 4.0.1 |
| 12 | combined-stream | 1.0.8 |
| 13 | core-util-is | 1.0.2 |
| 14 | dashdash | 1.14.1 |
| 15 | debug | 3.1.0 |
| 16 | delayed-stream | 1.0.0 |
| 17 | download-stats | 0.3.4 |
| 18 | ecc-jsbn | 0.1.2 |
| 19 | extend | 3.0.2 |
| 20 | extsprintf | 1.3.0 |
| 21 | fast-deep-equal | 3.1.3 |
| 22 | fast-json-stable-stringify | 2.1.0 |
| 23 | follow-redirects | 1.5.10 |
| 24 | forever-agent | 0.6.1 |
| 25 | form-data | 2.3.3 |
| 26 | getpass | 0.1.7 |
| 27 | har-schema | 2.0.0 |
| 28 | har-validator | 5.1.5 |
| 29 | http-signature | 1.2.0 |
| 30 | is-buffer | 1.1.6 |
| 31 | is-plain-object | 2.0.4 |
| 32 | is-typedarray | 1.0.0 |
| 33 | isobject | 3.0.1 |
| 34 | isstream | 0.1.2 |
| 35 | jsbn | 0.1.1 |
| 36 | json-schema | 0.2.3 |
| 37 | json-schema-traverse | 0.4.1 |
| 38 | json-stringify-safe | 5.0.1 |
| 39 | jsonparse | 1.3.1 |
| 40 | jsprim | 1.4.1 |
| 41 | kind-of | 6.0.3 |
| 42 | lazy-cache | 2.0.2 |
| 43 | mime-db | 1.44.0 |
| 44 | mime-types | 2.1.27 |
| 45 | moment | 2.27.0 |
| 46 | ms | 2.0.0 |
| 47 | npm-api | 1.0.0 |
| 48 | oauth-sign | 0.9.0 |
| 49 | paged-request | 2.0.1 |
| 50 | performance-now | 2.1.0 |
| 51 | psl | 1.8.0 |
| 52 | punycode | 2.1.1 |
| 53 | qs | 6.5.2 |
| 54 | request | 2.88.2 |
| 55 | safe-buffer | 5.2.1 |
| 56 | safer-buffer | 2.1.2 |
| 57 | set-getter | 0.1.0 |
| 58 | shallow-clone | 3.0.1 |
| 59 | sshpk | 1.16.1 |
| 60 | through | 2.3.8 |
| 61 | to-object-path | 0.3.0 |
| 62 | tough-cookie | 2.5.0 |
| 63 | tunnel-agent | 0.6.0 |
| 64 | tweetnacl | 0.14.5 |
| 65 | uri-js | 4.4.0 |
| 66 | uuid | 3.4.0 |
| 67 | verror | 1.10.0 |
There's one additional directory installed in node_modules called .bin
which is where binary executables of installed packages live, so
that's the difference.
We can see what commands are installed:
| |
total 20 lrwxrwxrwx 1 wschenk wschenk 20 Sep 9 14:26 JSONStream -> ../JSONStream/bin.js lrwxrwxrwx 1 wschenk wschenk 23 Sep 9 14:26 sshpk-conv -> ../sshpk/bin/sshpk-conv lrwxrwxrwx 1 wschenk wschenk 23 Sep 9 14:26 sshpk-sign -> ../sshpk/bin/sshpk-sign lrwxrwxrwx 1 wschenk wschenk 25 Sep 9 14:26 sshpk-verify -> ../sshpk/bin/sshpk-verify lrwxrwxrwx 1 wschenk wschenk 16 Sep 9 14:26 uuid -> ../uuid/bin/uuid
What are the specified deps
The structure of package-lock.json is much simpler than Gemfile.lock,
and it doesn't show which modules are the ones that the developer
specified and which are ones are derivatives. We can take a guess at
this by looking at modules that aren't another's dependancy.
| |
Which happily yields:
npm-api
So that looks correct for this project.
Loading project metadata from npm
The next thing we are looking for is the repository of the source code, so we can see what code there's out there, how well it's maintained, etc.
| |
Name npm-api
Version 1.0.0
Description Base class for retrieving data from the npm registry.
License MIT
Homepage https://github.com/doowb/npm-api
Repository { type: 'git', url: 'git+https://github.com/doowb/npm-api.git' }
Clean repo https://github.com/doowb/npm-api.git
Bug { url: 'https://github.com/doowb/npm-api/issues' }
Here we can see the repository is type git and the url has an
unexplained git+ in front of it. Why? I'd love to know. But we can
strip it out using the replace function to get something not
pointlessly redundant from the type sibling attribute.
Finding out of date dependencies
npm has a similar function to bundle outdated called… npm outdated.
Exciting! Lets recreate that now.
| |
Which dumps out:
| Module | Installed | Latest | Status |
| core-util-is | 1.0.2 | 1.0.2 | CURRENT |
| caseless | 0.12.0 | 0.12.0 | CURRENT |
| performance-now | 2.1.0 | 2.1.0 | CURRENT |
| clone-deep | 4.0.1 | 4.0.1 | CURRENT |
| isstream | 0.1.2 | 0.1.2 | CURRENT |
| ecc-jsbn | 0.1.2 | 0.2.0 | OUTDATED |
| json-stringify-safe | 5.0.1 | 5.0.1 | CURRENT |
| isobject | 3.0.1 | 4.0.0 | OUTDATED |
| asn1 | 0.2.4 | 0.2.4 | CURRENT |
| combined-stream | 1.0.8 | 1.0.8 | CURRENT |
| ms | 2.0.0 | 2.1.2 | OUTDATED |
| paged-request | 2.0.1 | 2.0.1 | CURRENT |
| fast-json-stable-stringify | 2.1.0 | 2.1.0 | CURRENT |
| extend | 3.0.2 | 3.0.2 | CURRENT |
| download-stats | 0.3.4 | 0.3.4 | CURRENT |
| asynckit | 0.4.0 | 0.4.0 | CURRENT |
| bcrypt-pbkdf | 1.0.2 | 1.0.2 | CURRENT |
| extsprintf | 1.3.0 | 1.4.0 | OUTDATED |
| tunnel-agent | 0.6.0 | 0.6.0 | CURRENT |
| lazy-cache | 2.0.2 | 2.0.2 | CURRENT |
| is-buffer | 1.1.6 | 2.0.4 | OUTDATED |
| aws-sign2 | 0.7.0 | 0.7.0 | CURRENT |
| jsbn | 0.1.1 | 1.1.0 | OUTDATED |
| har-schema | 2.0.0 | 2.0.0 | CURRENT |
| delayed-stream | 1.0.0 | 1.0.0 | CURRENT |
| dashdash | 1.14.1 | 2.0.0 | OUTDATED |
| forever-agent | 0.6.1 | 0.6.1 | CURRENT |
| safer-buffer | 2.1.2 | 2.1.2 | CURRENT |
| is-plain-object | 2.0.4 | 5.0.0 | OUTDATED |
| getpass | 0.1.7 | 0.1.7 | CURRENT |
| json-schema-traverse | 0.4.1 | 0.5.0 | OUTDATED |
| json-schema | 0.2.3 | 0.2.5 | OUTDATED |
| is-typedarray | 1.0.0 | 1.0.0 | CURRENT |
| punycode | 2.1.1 | 2.1.1 | CURRENT |
| http-signature | 1.2.0 | 1.3.5 | OUTDATED |
| to-object-path | 0.3.0 | 0.3.0 | CURRENT |
| verror | 1.10.0 | 1.10.0 | CURRENT |
| fast-deep-equal | 3.1.3 | 3.1.3 | CURRENT |
| through | 2.3.8 | 2.3.8 | CURRENT |
| jsonparse | 1.3.1 | 1.3.1 | CURRENT |
| shallow-clone | 3.0.1 | 3.0.1 | CURRENT |
| safe-buffer | 5.2.1 | 5.2.1 | CURRENT |
| jsprim | 1.4.1 | 2.0.0 | OUTDATED |
| npm-api | 1.0.0 | 1.0.0 | CURRENT |
| set-getter | 0.1.0 | 0.1.0 | CURRENT |
| oauth-sign | 0.9.0 | 0.9.0 | CURRENT |
| uri-js | 4.4.0 | 4.4.0 | CURRENT |
| follow-redirects | 1.5.10 | 1.13.0 | OUTDATED |
| kind-of | 6.0.3 | 6.0.3 | CURRENT |
| aws4 | 1.10.1 | 1.10.1 | CURRENT |
| mime-db | 1.44.0 | 1.45.0 | OUTDATED |
| sshpk | 1.16.1 | 1.16.1 | CURRENT |
| psl | 1.8.0 | 1.8.0 | CURRENT |
| mime-types | 2.1.27 | 2.1.27 | CURRENT |
| har-validator | 5.1.5 | 5.1.5 | CURRENT |
| form-data | 2.3.3 | 3.0.0 | OUTDATED |
| tweetnacl | 0.14.5 | 1.0.3 | OUTDATED |
| debug | 3.1.0 | 4.2.0 | OUTDATED |
| tough-cookie | 2.5.0 | 4.0.0 | OUTDATED |
| qs | 6.5.2 | 6.9.4 | OUTDATED |
| JSONStream | 1.3.5 | 1.3.5 | CURRENT |
| axios | 0.18.1 | 0.20.0 | OUTDATED |
| moment | 2.27.0 | 2.29.1 | OUTDATED |
| uuid | 3.4.0 | 8.3.1 | OUTDATED |
| request | 2.88.2 | 2.88.2 | CURRENT |
| assert-plus | 1.0.0 | 1.0.0 | CURRENT |
| ajv | 6.12.4 | 6.12.6 | OUTDATED |
Thoughts
As with our Gemfile exploration, we can
- Identify which
modulesare specified only from the lock file. - Look at all of the dependancies of the project to see which is out of date
- Find the git repo that the original code is packaged from.
The next step will be to start looking into the repos themselves to ask a few questions:
- Is the project maintained?
- What is the project activity?
- Is it a semver project?
- What patch/minor/major code has changed?
- How is the project connected to other projects?
Stay tuned!
Previously
Next