How can I avoid conflicting versions of a C library?

In sass-eyeglass/eyeglass#194, I was experiencing segfaults and assertion failures within C code. After a bit of debugging, I narrowed the problem down to conflicting versions of libsass, imported via different versions of node-sass.

Is there a way to force npm’s resolution of a particular module to a specific version, not only for my top-level project, but for all dependencies of any depth?

Alternatively, is there a good way to assert, after installing, that there are no conflicting versions of a specific library?

There is not currently a way to lock down the version of a sub-dependency like you’re describing (but stay tuned! this feature is in the works). You may be able to fix the current problem with https://www.npmjs.com/package/replace-deep-dep. And you could follow up with node-sass directly, so that they lock this down better in future releases.

If you do want to follow up with node-sass, the change isn’t in the package list, but has to do with asserting the module as a singleton when required. The usual approach to this is to store something on a global object. An example: https://github.com/iarna/iarna-lib/blob/master/index.js#L7-L9