Sometimes I need the full Composer dependency name but I only know part of it. For example, I may know Block X-ray Attributes is a Composer dependency but I don’t remember the full package name. While I could open the composer.json file and find the dependency, I can also leverage jq to do the work for me.
jq
Automatically Switch Node Version in Zsh from package.json
Add this code to $HOME/.zshrc to automatically set the node version to match the version in package.json.
Compare composer.json on Two Different Git Branches
I have composer.json files on two different branches and I want to compare their (non-dev) dependencies. This is the command I run to compare the “require” section of composer.json on my current branch to the “require” section of composer.json on another branch.
Using jq and nvm to set Node version
The nvm command allows you to switch between versions of node. Often a project will include a .nvmrc file to specify the version of node to use. Even if a project does not contain an .nvmrc file, you may be able to read the preferred node version from package.json and use that value with nvm.