Sanity check: Rhino does not have a require function, right?

泄露秘密 提交于 2019-12-06 00:24:54

require is a CommonJS spec that node.js (and other frameworks, like RingoJS) use. The newest version of Rhino does support require, but the one that ships with the JVM does not.

To work around it, you could either use Rhino directly instead of the javax.script interface, or implement the CommonJS module system yourself. You might be able to drop in the newer Rhino version in place of the JVM's, but I have no idea if that would work or not.

You might need to use something like RingoJS though, since there are other CommonJS specs that are probably assumed to be there and aren't supported by Rhino natively. Of course, there would still be issues with libraries that depend on node.js-specific features.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!