-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Observations on npm's behavior #11
Draft
rotu
wants to merge
2
commits into
openjs-foundation:main
Choose a base branch
from
rotu:patch-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,13 @@ Analysis of the `name` property | |
- `npm config set <Scope>:registry <Registry URL>` or `npm login --registry=<Registry URL> --scope=<Scope>` (`<Scope>` must include the `@` symbol). | ||
- One scope must only ever point to one registry. | ||
- One registry can host multiple scopes. | ||
- Observations from [email protected]: | ||
- `npm install` installs dependencies listed in the current `package.json`. | ||
- `npm install ./some/folder` will fail if `some/folder/package.json` is missing a `name`. | ||
- `npm install alias@./some/folder` can install even if `./some/folder/package.json` does not exist. | ||
- `npm install alias@./some/folder --install-links` can install even if `./some/folder/package.json` does not have a `name` nor `version`. | ||
- `npm publish` and `npm pack` require both `name` and `version`. | ||
- `npm view` and `npm docs`, when run inside a directory with a `package.json`, show information about the latest published version of the package with matching name on `npm` (even if unrelated). This suggests that even unpublished packages should have globally unique names (e.g. by using a scoped name). | ||
|
||
## Sources | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing this is a WIP? Sorry if this is too early of a comment, but I think we should avoid documenting too many specific behaviors. The goal would likely be to call out specifically any unexpected behaviors around the
name
field specifically but not much else. Does that make sense?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good feedback. yes, a little early, and my additions in this PR definitely need organizing and elaboration.
I think the behavior shows that the description of the
name
field innpm
is (understandably) assuming you are only thinking ofpackage.json
describing a package being added to or installed from a registry. At runtime, whenpackage.json
is in a module in yournode_modules
folder, thename
field is essentially unused.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… except when it's got an exports field and is self-referencing - then it's quite used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ljharb True! I don’t understand how widespread self-import is. (I didn’t even know it was a special case instead of just
node_modules
resolution until a day ago or so!) Do you know if there are any stats?I personally have been using relative URL imports inside a package so as not to repeat the package name everywhere and so I can run my code in a browser without transpilation/bundling.