Closed morfeusys closed 8 years ago
Could you provide a reproducer ?
@cescoffier Sorry, didn't get it.. I've provided both js script and package.json files to reproduce it. What else have I to do?
If you can come up with a githup project with these files and a readme file with the instructions like:
vertx run ....
That would save us some time.
@cescoffier Not OP but I'm having this issue too. Here's a reproducer: https://github.com/ejmurra/error_reproducer_vertx.git
It seems that top level require statements such as require('request') error out when the requested module makes another request for a peer dependency (in this case node_modules/request/index.js:17
).
I'm running OSX 10.10.5
Thanks ! Gonna have a look.
vert.x javascript is not based on node, even though we can load node modules once a module requires a native node such as fs
or http
(as required by express and request) in the reports it won't run.
vert.x uses nashorn to run scripts as long as your node modules are pure javascript without using any node API they should work. For example you can run template engines like handlebars, react or any module you could run on a browser.
@pmlopes That makes sense to me.
What confuses me is that the error is thrown here which points to this file which has no dependencies (native node modules or otherwise). This leads me to think that nashorn is tracing the require('request')
line to the request module in node_modules but any require
calls after that are no longer looking in the node_modules directory.
You have a corrupted node_modules
directory. From your reproducer, I've deleted the directory node_modules
and re-download the dependencies with:
npm install
After that I run your example:
npm start
And got the error:
[plopes@heimdall error_reproducer_vertx]$ npm start
> vertx_reproducer@1.0.0 start /home/plopes/Projects/error_reproducer_vertx
> ./node_modules/.bin/vertx run server.js
javax.script.ScriptException: Error: Cannot find module net 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$163(DeploymentManager.java:429)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$18(ContextImpl.java:335)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)
Caused by: <eval>:141:6 Error: Cannot find module net
And this leads back to what I've written before, net
is a node.js core module, you cannot see it on vert.x.
Hi! I have js verticle and package.json contains:
npm-test.js file contains:
After
npm install
I'm trying to runvertx run npm-test.js
but this puts "Cannot find module fs" error in my console. Of course my $NODE_PATH points to the right node's installation dir. What should I do to resolve this issue?