Skip to content
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

Feature: make npm view for current project easier #6390

Closed
RobinKnipe opened this issue Apr 22, 2023 · 4 comments
Closed

Feature: make npm view for current project easier #6390

RobinKnipe opened this issue Apr 22, 2023 · 4 comments

Comments

@RobinKnipe
Copy link
Contributor

Currently using npm view will return information about the project associated with the current working directory. This is very useful, but to use any of the extended options of the command (like [<field>[.subfield]...]) requires supplying a package name.

npm view
# information about the local project from the registry indicated by package.json

npm view <package>
# information from the registry about the specified package

npm view <package> version
# the latest version of the specified package

# possibly the same as the above for the local project, but not as friendly :(
npm view `npm pkg get name | tr -d '"'` version

Feature - consider a shorthand for the local context, e.g.

npm view - version
# uses the local package.json to work out the registry and latest published version
@wraithgar
Copy link
Member

wraithgar commented Apr 24, 2023

npm pkg is what you're looking for to query the local package.json
npm view . [attr] is what you're looking for to query information about the package defined in the local package.json

@RobinKnipe
Copy link
Contributor Author

Oh . you say!? Cool, I guess an addition to the docs would be useful. Sadly it doesn't seem to read the publishConfig definition from the local package.json though:

"publishConfig": {
    "registry": "https://npm.pkg.github.com"
  }
npm v . version
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@rkeu%2fserverless-health-check - Not found
npm ERR! 404 
npm ERR! 404  '@rkeu/serverless-health-check@*' is not in this registry.

@ljharb
Copy link
Contributor

ljharb commented Apr 27, 2023

That's because it's a publish config, not a registry config - if you want it to do that, you should also have an .npmrc in the project that sets registry=https://npm.pkg.github.com or similar.

@RobinKnipe
Copy link
Contributor Author

Thanks @ljharb - it's a shame though, I was trying to avoid having to use an .npmrc file, because I'd much rather have everything configured in one place through the package.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants