vertx 无法部署节点模块
vertx unable to deploy a node module
我正在将 vertx 与 npm 一起使用,我想将 googleapis 包含到我的一个 verticle 中。为此,我使用 npm 在项目中安装了 googleapis。
package.json中的节点依赖如下:
{
"name": "grey-bshlv",
"dependencies": {
"angular": "^1.5.7",
"googleapis": "^10.0.0",
"vertx3-full": "^3.3.0"
},
"scripts": {
"start": "./node_modules/.bin/vertx run server.js"
}
server.js
的内容
var Router = require("vertx-web-js/router");
var eb = vertx.eventBus();
var google = require("googleapis");
vertx.deployVerticle("verticles/static-data-verticle.js");
现在,当我启动 vertx 时,我不断收到错误 "javax.script.ScriptException: Error: Cannot find module googleapis in at line number 141 at column number 6"
下面提供了完整的错误堆栈:
javax.script.ScriptException: Error: Cannot find module googleapis in <eval> at line number 141 at column number 6
at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:467)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:451)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:403)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:399)
at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at io.vertx.lang.js.JSVerticleFactory$JSVerticle.start(JSVerticleFactory.java:109)
at io.vertx.core.impl.DeploymentManager.lambda$doDeploy(DeploymentManager.java:434)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask(ContextImpl.java:359)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:339)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:393)
at io.netty.util.concurrent.SingleThreadEventExecutor.run(SingleThreadEventExecutor.java:742)
at java.lang.Thread.run(Thread.java:745)
Caused by: <eval>:141:6 Error: Cannot find module googleapis
at jdk.nashorn.internal.objects.NativeError.initException(NativeError.java:137)
at jdk.nashorn.internal.objects.NativeError.<init>(NativeError.java:102)
at jdk.nashorn.internal.objects.NativeError.<init>(NativeError.java:106)
at jdk.nashorn.internal.objects.NativeError.<init>(NativeError.java:110)
at jdk.nashorn.internal.objects.NativeError.constructor(NativeError.java:129)
at jdk.nashorn.internal.scripts.Script$Recompilation76AAAA$\^eval\_.L:33$doRequire(null:141)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:631)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptFunction.invokeSync(ScriptFunction.java:1287)
at jdk.nashorn.internal.scripts.Script$Recompilation49AAA$\^eval\_.L:33$Require(null:120)
at jdk.nashorn.internal.scripts.Script$Recompilation09A$\^eval\_.L:33$Module$require(null:68)
at jdk.nashorn.internal.scripts.Script$Recompilation4AAAAA$\^eval\_#88\!17\^eval\_.L:1(server.js:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:633)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
at jdk.nashorn.internal.scripts.Script$Recompilation35AAAAA$\^eval\_.L:33$_load(null:113)
at jdk.nashorn.internal.scripts.Script$Recompilation76AAAA$\^eval\_.L:33$doRequire(null:154)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:631)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptFunction.invokeSync(ScriptFunction.java:1287)
at jdk.nashorn.internal.scripts.Script$Recompilation268AAZ$\^eval\_.L:33$RequireNoCache(null:124)
at jdk.nashorn.internal.scripts.Script1$\^eval\_.:program(<eval>:1)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:623)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:446)
... 11 more
Failed in deploying verticle
Nashorn 本质上 Vert.x 不是 Node,因此模块如:
- fs
- 路径
- 网
将不可用,因为它们是节点 specific/native。如果您的依赖项需要这些模块中的任何一个,则无法在 nashorn 中使用它们,因此 vert.x.
文档中有关于它的警告:
我正在将 vertx 与 npm 一起使用,我想将 googleapis 包含到我的一个 verticle 中。为此,我使用 npm 在项目中安装了 googleapis。 package.json中的节点依赖如下:
{
"name": "grey-bshlv",
"dependencies": {
"angular": "^1.5.7",
"googleapis": "^10.0.0",
"vertx3-full": "^3.3.0"
},
"scripts": {
"start": "./node_modules/.bin/vertx run server.js"
}
server.js
的内容var Router = require("vertx-web-js/router");
var eb = vertx.eventBus();
var google = require("googleapis");
vertx.deployVerticle("verticles/static-data-verticle.js");
现在,当我启动 vertx 时,我不断收到错误 "javax.script.ScriptException: Error: Cannot find module googleapis in at line number 141 at column number 6"
下面提供了完整的错误堆栈:
javax.script.ScriptException: Error: Cannot find module googleapis in <eval> at line number 141 at column number 6
at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:467)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:451)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:403)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:399)
at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at io.vertx.lang.js.JSVerticleFactory$JSVerticle.start(JSVerticleFactory.java:109)
at io.vertx.core.impl.DeploymentManager.lambda$doDeploy(DeploymentManager.java:434)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask(ContextImpl.java:359)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:339)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:393)
at io.netty.util.concurrent.SingleThreadEventExecutor.run(SingleThreadEventExecutor.java:742)
at java.lang.Thread.run(Thread.java:745)
Caused by: <eval>:141:6 Error: Cannot find module googleapis
at jdk.nashorn.internal.objects.NativeError.initException(NativeError.java:137)
at jdk.nashorn.internal.objects.NativeError.<init>(NativeError.java:102)
at jdk.nashorn.internal.objects.NativeError.<init>(NativeError.java:106)
at jdk.nashorn.internal.objects.NativeError.<init>(NativeError.java:110)
at jdk.nashorn.internal.objects.NativeError.constructor(NativeError.java:129)
at jdk.nashorn.internal.scripts.Script$Recompilation76AAAA$\^eval\_.L:33$doRequire(null:141)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:631)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptFunction.invokeSync(ScriptFunction.java:1287)
at jdk.nashorn.internal.scripts.Script$Recompilation49AAA$\^eval\_.L:33$Require(null:120)
at jdk.nashorn.internal.scripts.Script$Recompilation09A$\^eval\_.L:33$Module$require(null:68)
at jdk.nashorn.internal.scripts.Script$Recompilation4AAAAA$\^eval\_#88\!17\^eval\_.L:1(server.js:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:633)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
at jdk.nashorn.internal.scripts.Script$Recompilation35AAAAA$\^eval\_.L:33$_load(null:113)
at jdk.nashorn.internal.scripts.Script$Recompilation76AAAA$\^eval\_.L:33$doRequire(null:154)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:631)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptFunction.invokeSync(ScriptFunction.java:1287)
at jdk.nashorn.internal.scripts.Script$Recompilation268AAZ$\^eval\_.L:33$RequireNoCache(null:124)
at jdk.nashorn.internal.scripts.Script1$\^eval\_.:program(<eval>:1)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:623)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:446)
... 11 more
Failed in deploying verticle
Nashorn 本质上 Vert.x 不是 Node,因此模块如:
- fs
- 路径
- 网
将不可用,因为它们是节点 specific/native。如果您的依赖项需要这些模块中的任何一个,则无法在 nashorn 中使用它们,因此 vert.x.
文档中有关于它的警告: