Skip to content

Commit 9f818e8

Browse files
Max Blackowlstronaut
authored andcommitted
docs(npm-view): clarify object property access syntax and provide examples
1 parent 39c2f2e commit 9f818e8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/lib/content/commands/npm-view.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,22 @@ If the field value you are querying for is a property of an object, you should r
7070
npm view express time'[4.8.0]'
7171
```
7272

73+
Note: When accessing object properties that contain special characters or numeric keys, you need to use quotes around the key name.
74+
For example, to get the publish time of a specific version:
75+
76+
```bash
77+
npm view express "time[4.17.1]"
78+
```
79+
80+
Without quotes, the shell may interpret the square brackets as glob patterns, causing the command to fail.
81+
You can also access the time field for a specific version by specifying the version in the package descriptor:
82+
83+
```bash
84+
npm view [email protected] time
85+
```
86+
87+
This will return all version-time pairs, but the context will be for that specific version.
88+
7389
Multiple fields may be specified, and will be printed one after another.
7490
For example, to get all the contributor names and email addresses, you can do this:
7591

0 commit comments

Comments
 (0)