我正在使用带有npm的vertx,我想将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:错误:无法在第6列第141行找到模块googleapis”
完整的错误堆栈如下:
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$8(DeploymentManager.java:434)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$3(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$5.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$Recompilation$4$4376AAAA$\^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$Recompilation$3$4049AAA$\^eval\_.L:33$Require(null:120)
at jdk.nashorn.internal.scripts.Script$Recompilation$18$2109A$\^eval\_.L:33$Module$require(null:68)
at jdk.nashorn.internal.scripts.Script$Recompilation$134$57AAAAA$\^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$Recompilation$14$2235AAAAA$\^eval\_.L:33$_load(null:113)
at jdk.nashorn.internal.scripts.Script$Recompilation$4$4376AAAA$\^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$Recompilation$132$4168AAZ$\^eval\_.L:33$RequireNoCache(null:124)
at jdk.nashorn.internal.scripts.Script$131$\^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
答案 0 :(得分:0)
Nashorn和固有的Vert.x不是Node所以模块如:
由于它们是特定于节点/本机的,因此无法使用。如果您的依赖项需要任何这些模块,则无法在nashorn中使用它们,因此无法在vert.x中使用它们。
关于它的文档有一个警告: