DEV Community

Kevin John Mulligan
Kevin John Mulligan

Posted on

Resolving a common mistake with `jq`

jq is a lightweight and flexible command-line JSON processor.

Scenario:

You may want to use jq to display the package.json file you are working on in a JS project but you're likely to encounter this error.

jq package.json

jq: error: package/0 is not defined at <top-level>, line 1:
package.json
jq: 1 compile error
Enter fullscreen mode Exit fullscreen mode

Resolution:

The correct syntax includes an additional . which specifies which filter to use.
jq . package.json

From the website

The absolute simplest filter is .. This is a filter that takes its input and produces it unchanged as output. That is, this is the identity operator.

Top comments (0)