Is there any way to search among scoped packages in npm? - node.js

Is there any way to search among scoped packages? I have access to a private repository so I would like to see what packages are available there and try to figure out the package names. I totally understand that, if somebody doesn't have access to a repository then they mustn't see the content of it. But what about those who have access and would like to use it effectively?
Documentation doesn't help, however it is a basic scenario for me.

Depends on what branch you will be checking out. Anyway you could simply check out the main branch and look into the package.json file. Under dependencies there will be listed all the npm packages that the project is using. One other way would be to manually search through the node-modules folder.

Related

Packages that are not updated when running meteor

I alter some code in a package at
C:\Users\usr\AppData\Local\.meteor\packages\accounts-ui-unstyled\1.3.0\web.browser\login_buttons.js
The thing is , after I alter the code and run “meteor” in the command line the changes are not implemented, I even deleted the whole package mentioned before and run the app and it was like … nothing happened, it’s like the application have some sort of a cache of the packages that he doesn’t have to go to that path to get them , instead it uses what it had from it before.
Can anyone please explain this to me ? What’s happening here ?
The correct way of "changing" a package is to git clone the package from git (or otherwise retrieve it's source) into either a project internal /packages folder or a project external folder (requires environment variable METOER_PACKAGE_DIRS).
If the package is, as in your case, a Meteor internal package, you can also copy only the package into your project and even add it to your versioning.
In this package you then apply your changes. It will be used in favor of the atmosphere package.
A good practice is to also increment the package version, so it is known for everyone that a custom version is in use.
Why you should not change packages inside the users \Users\...\.meteor installation packages folder?
This is the path to packages, that will be used as defaults for every new meteor project you create. Deep changes can create deep damage to your projects since changing a package will apply to all dependent projects.
Think also about project specific customization. The above described method will allow this, too.

How can I see who uses an NPM package on Github?

I would like to see how open-source projects use a particular NPM module.
Let's say I would like to find projects using the "normalizr" NPM package.
If I type "normalizr" into Github, I will get a bunch of forks and unrelated projects.
I really just want to see who has "normalizr" in their package.json file.
You can see that on NPM website.
For example, go to normalizr, on right side look for Dependents section where all the dependents are listed. From there you can find their respective github/other repository links. Hope this helps.

Is there a way to check update for particular npm package using rss/atom or other similar way?

I found only this thread when an user ask similar question but without answer. ( https://github.com/npm/npm-registry-couchapp/issues/17 )
I know two sites that are repositories of NPM packages:
https://www.npmjs.com
http://libraries.io
And I can't find a way to obtain an rss for single package in a way like it is done for github or sourceforge:
https://github.com/<author_name>/<package_name>/releases.atom
http://sourceforge.net/projects/<project_name>/rss?limit=20
And yes, i know that I might check what is the github repository for given NPM and do it that way, but I specifically ask for a way to reach this info from some kind of NMP repository that tracks if a given package changed its git address (not necessarily these two I added here as example.)
It is hard to find these tricks by google because it thinks I'm searching for some kind of NPM package that deals with RSS/ATOM.
I've recently added a release atom feed to all packages on libraries.io, simply add /versions.atom to the end of any project page url, for example:
https://libraries.io/npm/node-sass/versions.atom
With npm modules it should never be more than 10 minutes delayed in showing the newest version.
You need to hit your requests against an NPM registry, i.e. https://registry.npmjs.org/-/rss.
For single packages, the URL should be https://registry.npmjs.org/-/rss/browserfiy, but the responses aren't being constructed correctly at the time of writing.
Alternatively, you could go for a JSON response, i.e. https://registry.npmjs.org/browserify. For a more programmatic way of accessing package details, you can use npm-registry-client.

How to deal with local package dependencies in nodejs with npm

How should we deal with local packages that are a dependency in other local packages?
For simplicities sake, say we have the follow packages
api - express application
people - a package to deal with people
data-access - a package that deals with data access
And then the dependencies are
api depends on people
people depends on data-access
Currently we have these dependencies setup as file dependencies.
I.e. api package.json would have
"dependencies": {
"people": "file:../people"
}
Trouble with this is that we're finding it a PITA when we make updates to one package and want those changes in the other packages that depend on it.
The options we have thought of are:
npm install - but this won't overwrite previously installed packages if changes are made, so we have to delete the old one from the node_modules directory and re-run npm install... which can be niggly if the package dependency is deep.
npm link - we're not sold on the idea because it doesn't survive version control... Just thinking about it now, maybe we have some kind of local build script that would run the npm link commands for us... this way it could survive version control. Would that be a grunt job?
grunt - we haven't dived too deep into this one yet, but it feels like a good direction. A little bit of googling we came accross this: https://github.com/ahutchings/grunt-install-dependencies
So, what option would work best for our situation?
Are there other options that we haven't thought of yet?
Ps. we're a .NET shop doing a PoC in node, so assume we know nothing!
Pps. if you strongly believe we're setting up our project incorrectly and we shouldn't have smaller individual packages, let me know in the comments with a link to some reading on the subject.
So, I agree that going with 'many small packages' is usually a good idea. Check out 12factor.net if you haven't already.
That said, in specific answer to your question I'd say your best bet is to consider mainly how you want to maintain them.
If the 'subcomponents' are all just parts of your app (as, for example, data-access implies), then I'd keep them in the same folder structure, not map them in package.json at all, and just require them where you need them. In this case, everything versions together and is part of the same git repository.
If you really want to or need to keep them all in separate git repositories, then you can do npm link, but to be honest I've found it more useful to just use the URL syntax in package.json:
dependencies: {
"people" : "git://path.to.git:repo#version.number"
}
Then, when you want to explicitly update one of your dependencies, you just have to bump the version number in your package.json and run npm install again.

Which Node.js project uses a given dependency?

I have a folder that contains all my cloned GitHub repositories. Now I would like to get a list of all the repositories that reference a given dependency.
I think of something such as:
$ whouses async
And then I'd like to get a list of all repositories, where async is either referenced as a dependency or a devDependency. Basically, all whouses would need to do is to enter each sub-folder of the current folder and check the package.json file.
Is there a tool available that does this, or am I better off writing one for myself?
Well, there's a way to browse the npm registry for all published modules that depend on a library: https://npmjs.org/browse/depended/async. That may help you a bit. For a local set of modules I don't know off the top of my head if anything exists already or not.

Resources