Modules not found with eval

If you eval a require statement the module is not found.

by example

eval(‘require(“express”)’)

Will give you ‘can not find module express’

Is there a way to make this work other than expressly loading modules before the eval statement?

Hi there!

Right now the way RunKit determines which packages you’re using is to crawl the AST and find the specific requires. So unfortunately unless you require the package at the top level, it will not be available if you eval it.

We’re looking into different ways to give users a way to specify something like a shrinkwrap, which could get around this issue… but that’s probably a ways away.

Hope this helps!
- Randy

Thanks for the reply. Is there any underlying RunKit API I could use (the same one as is called by the loader?), or is it too late by runtime?

Thanks
Ralph

Unfortunately there is no API at this time. Can you explain in a little more detail what you want to do? It might be helpful in the future when we look at building an API.

Thanks,
- Randy

I am allowing dependancies from github, it works just fine, except for dependancies from NPM. So as you mention i need to for each dependancy explicitly include the sub dependancies before I remote load it.