I’m having trouble figuring out how to look for packages in the NPM registry that aren’t installed on my machine yet. I’m using NPM version 0.2.19 and when I run npm ls or npm search, these commands only show me the packages I already have locally installed.
I checked the help documentation and found this confusing part about configuration:
CONFIGURATION
listopts
Default: ""
A whitespace-separated list of extra args that are always passed to npm ls
For example: listopts = remote
npm ls
The output here will always filter by remote
Does this mean I need to modify some config file to search the remote registry? Or is there a direct command I can use to browse available packages online without installing them first?
The configuration you mentioned is indeed crucial for your situation. By setting listopts to include remote, you enable npm to search the remote registry rather than just your local packages. To do this, run npm config set listopts remote first. After that, executing npm ls will list packages available in the remote registry. Alternatively, you can simply use npm ls remote to bypass the config change. I encountered similar issues when I began using npm, and navigating the older documentation was quite a challenge. Once you have the remote option set up, you’ll easily access the available packages online without needing to install them first.
You can use npm search <package-name> with the remote flag to search the registry directly. Just run npm search remote <search-term> and it’ll query the remote NPM registry instead of your local packages. I had the same confusion with that older version - the docs weren’t clear back then. You can also try npm view <package-name> to get detailed info about a specific package from the registry. This works great when you know roughly what you’re looking for but want to verify it exists and check details before installing. The remote functionality was pretty hidden in those early versions, but it makes package discovery way easier once you figure it out.
yeah, older npm versions can be a pain. try npm config list to see your settings, then add remote to listopts. or just use npm info <packagename> since it gets data from the registry by default. that worked for me before i upgraded.