package.json & requirements.txt Viewer · Tutorial
How to review npm dependencies in a package.json
6 min readbeginnerUpdated
A teammate opened a pull request that changes package.json. Before you approve it, you want to know whether any dependency could pull in an unexpected major version. You will paste the file and work through the flagged entries.
What you need
- The package.json Viewer
- The project’s package.json
Steps
Paste the file
Load the example. The summary shows 12 dependencies, several of them worth checking.
Show only the flagged entries
Tick Only show entries worth checking.
lodashaccepts any version,vitehas no upper limit,chart-libcomes from GitHub andreactappears in both dependency lists.Fix loose ranges
Replace
*and>=6with caret ranges such as^4.17.21and^6.3.0. Paste the new values into the Semver Checker if you are unsure what they allow."lodash": "^4.17.21", "vite": "^6.3.0"Remove the duplicate
A package needed at runtime belongs in
dependenciesonly. DeletereactfromdevDependencies.Decide about Git dependencies
github:northwind/chart-lib#v2.1.0is pinned to a tag, which is reasonable. A branch name instead of a tag would change under you; publish the package to a registry if you can.
Try it yourself
Opens the package.json & requirements.txt Viewer with this tutorial's sample loaded.
Common mistakes
- Ignoring the lock file
- The lock file decides what is installed today. Loose ranges matter when it is regenerated, for example after
npm updateor in a new project. - Pinning everything in a library
- Exact versions in a published library force duplicate copies on its users. Pin in applications, use ranges in libraries.
Next steps
Go back to the package.json & requirements.txt Viewer, or keep going with one of these: