【发布时间】:2015-12-15 17:18:04
【问题描述】:
我正在尝试使用 babel.transform 而不是 JSXTranformer 进行反应。
...
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine nashorn = mgr.getEngineByName("nashorn");
nashorn.eval("var process = {env:{}}"); // node-modules expect that
nashorn.eval(getScript("com/facebook/babel/jvm-npm.js"));
babel = (JSObject) nashorn.eval("require('babel');");
...
babel 和 babel-core 安装为全局节点模块,出现错误:
测试套件:com.my.app.BabelTransformerTest
找不到模块 ./lib/api/node.js
无法加载模块 babel-core LOAD_ERROR
无法加载模块 babel LOAD_ERROR
无法加载模块 babel-core LOAD_ERROR
无法加载模块 babel LOAD_ERROR
找不到模块 ./lib/api/node.js
无法加载模块 babel-core LOAD_ERROR
无法加载模块 babel LOAD_ERROR
./lib/api/node.js 在 C:\Users\***\AppData\Roaming\npm\node_modules 中
听说可以从 Nashorn 运行babel.transform?
也许有办法只将 babel 的某些模块加载为 JavaScript 文件?
【问题讨论】:
-
只是好奇,你为什么使用 nashorn 而不是常规的 Node.js?
-
这是一个图书馆。对于更大的 Java 项目。我想是的……
标签: javascript node.js reactjs babeljs nashorn