Skip to content

Commit 95d25cd

Browse files
Max Blackowlstronaut
authored andcommitted
docs(package-json): clarify repository field normalization during publish
1 parent a367f9b commit 95d25cd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/lib/content/configuring-npm/package-json.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,19 @@ For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same
502502
}
503503
```
504504

505+
**Note on normalization:** When you publish a package, npm normalizes the `repository` field to the full object format with a `url` property. If you use a shorthand format (like `"npm/example"`), you'll see a warning during `npm publish` indicating that the field was auto-corrected. While the shorthand format currently works, it's recommended to use the full object format in your `package.json` to avoid warnings and ensure future compatibility:
506+
507+
```json
508+
{
509+
"repository": {
510+
"type": "git",
511+
"url": "git+https://github.com/npm/example.git"
512+
}
513+
}
514+
```
515+
516+
You can run `npm pkg fix` to automatically convert shorthand formats to the normalized object format.
517+
505518
If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
506519

507520
```json

0 commit comments

Comments
 (0)