Dependent Package Not Found

From https://npm.runkit.com/@kingjs/packages I run:

var assertThrows = require("@kingjs/assert-throws")

Which unexpectedly fails with “Error: Cannot find module ‘@kingjs/assert’”

@kingjs/packages depends on:

  • @kingjs/assert and
  • @kingjs/assert-throws

@kingjs/assert-throws requires but does not include it in it’s list of dependencies:

  • @kingjs/assert

I figured when @kingjs/assert-throws tried to load @kingjs/assert it would succeed because @kingjs/packages depended on it. But didn’t work…

Unfortunately I’m unable to replicate the behavior you saw because @kingjs/packages has a reference error immediately after the requires resolve:

https://runkit.com/me1000/5b6368c4d9644e00126362cc

- Randy

Randy, I’ve got another reproduction.

https://runkit.com/embed/yltht51q18en

I expect the code to run as is but I actually need to un-comment the require('@kingjs/define-generator'); line.

ps.
Sorry about that last one. I pushed a fix which broke the reproduction.

Cool, thanks for following up. The issue here appears to just be that you didn’t add @kingjs/define-generator to the dependencies in the package.json: https://npm.runkit.com/@kingjs/linq/package.json?t=1534438154343

Thanks!

If package A depends on package B which depends on package C, then I expected A’s package.json to only list B in its dependencies and yet still be able to load B successfully because I expected RunKit to walk the poset of dependencies, discover C, and ensure it’s available before launching A.

Is this not preferable?

Otherwise A has to include the closure of all its dependencies to get RunKit support even though locally its not required as NPM installs the closure for me.

Oh, my bad… I didn’t see that it was a different linq package bringing in define-generator. You’re right RunKit should (and will) crawl the dependencies, however linq.concat also doesn’t include genie-generator as a dependency (only a devDepenedency):
https://npm.runkit.com/@kingjs/linq.concat/package.json?t=1534448173175

Ah! Thanks so much for tracking that down!

So, devDependencies are EVIL!