scalajs-io / nodejs

This project provides Scala.js type-safe bindings for Node.js (current) v8.7.0 and LTS v6.11.4 APIs. The platform supports MEAN (MongoDB, Express, AngularJs, NodeJS), Cassandra, MySQL and many other npm projects.
Apache License 2.0
162 stars 28 forks source link

getting a reference to the global require object #1

Closed daenenk closed 8 years ago

daenenk commented 8 years ago

I tried

val require = scala.scalajs.js.Dynamic.global.require.asInstanceOf[org.scalajs.nodejs.NodeRequire]

which works when I launch my code with run in sbt. But when I launch my code with node from command line, require is not defined.

ldaniels528 commented 8 years ago

I've run into the same problems, and I'm not sure why we can't get a reference to require in the traditional way. As a result, I've been using a bootstrap JavaScript launcher, as shown in the integration guidance:

https://github.com/ldaniels528/scalajs-nodejs#node_integration