Open chefhoobajoob opened 7 years ago
I can confirm from our implementation that jvm-npm.js
is not finding the node_modules
directory in the js verticle's jar from the classpath.
if I change the require
statements in some-helper-script.js
from this:
require('jsonpatch-to-mongodb');
...to this:
require('./node_modules/jsonpatch-to-mongodb/index.js');
...then the require
statement in some-helper-script.js
resolves correctly. But, of course, it breaks when it encounters this require
statement in jsonpatch-to-mongodb
:
require('jsonpath-to-dot');
...which is a node dependency of jsonpatch-to-mongodb
, also located in the same node_modules
directory as a peer to jsonpatch-to-mongodb
in the verticle's jar.
We don't yet have a simple reproducer for this problem, but maybe I can describe what we are doing and the problem we are seeing, and somebody can help understand whether our expectations are wrong.
We have a javascript verticle whose scripts we are packaging up into a jar. The verticle makes use of several different node module dependencies, which we are staging into a
node_modules
directory.So, the jar layout is like this:
META-INF/MANIFEST.MF
verticle-name/verticle-impl.js
verticle-name/some-helper-script.js
verticle-name/node_modules/rql
verticle-name/node_modules/rxjs
verticle-name/node_modules/...<various other node dependencies>
verticle-impl.js
uses arequire
statement to use functions fromsome-helper-script.js
, and thesome-helper-script.js
usesrequire
statements to pull in its node module dependencies.We then make this jar available to dependent projects that want to launch the js verticle. We do this using the service factory, where the value of the
main
property of the service descriptor is set to:verticle-name/verticle-impl.js
.We have verified that the jar with the layout above is in the classpath of the dependent project at runtime.
However, while the dependent project is able to successfully locate the verticle and invoke its
start
method, and therequire
statements inverticle-imple.js
are successfully findingsome-helper-script.js
, we are finding that when evaluation gets to therequire
statements insome-helper-script.js
for the node modules in thenode_modules
directory, Nashorn complains that it can't find therequire
d module.Assuming no other problems in our implementation, should this organization be able to successfully resolve these
require
statements insome-helper-script.js
?