Closed moea closed 9 years ago
I'm definitely not the person to ask what would be reasonable w.r.t. node. Can NODE_PATH not be changed at runtime (from within the script)? The middleware knows nothing of the runner scripts, and that should stay that way.
Yeah, it looks like it can (module.paths is writable). Sticking the cwd in there before loading anything seems like it would fix more issues than it'd create. Let me know how you feel about a patch.
I ran into the same issue as @moea, which I solved by adding NODE_PATH=./node_modules
before lein cljsbuild test
. That was simple enough. Then I ran into another issue. I have tests that require passing in files, so I'd have some test files in my project directory, but I couldn't access them because Node's __dirname would be set to /tmp
instead of the directory I called the test from. I know that I could just set another environment variable, but that's an annoying workaround.
@cemerick Is there any reason why :node-runner uses /tmp as the working directory? Just having it use the directory where lein cljsbuild test
was called from would solve my issues and @moea's.
Sorry for the troubles, but I've deprecated this project. Please see the notice at the top of the repo's README. This is a good thing, fundamentally. :-)
Thanks for the project.
I'm not at all experienced with node, however with 0.12.5,
node /tmp/runner target
(the expansion of:node-runner
) will only look inside/tmp
for anode_modules
directory, unless directed otherwise. Would it be weird to do something withNODE_PATH
in the middleware (e.g. include the Leiningen project directory)? Or this something you'd expect users to configure themselves?