Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find node on Windows #38

Open
bleggett opened this issue Sep 27, 2016 · 10 comments
Open

Cannot find node on Windows #38

bleggett opened this issue Sep 27, 2016 · 10 comments

Comments

@bleggett
Copy link

bleggett commented Sep 27, 2016

This is likely a pathing issue, but running mocha results in

-*- mode: mocha-compilation; default-directory: "c:/Source/MyProject/" -*-
Mocha started at Tue Sep 27 15:13:46

 node node_modules/.bin/mocha --recursive --reporter dot c:/Source/MyProject/tests/client/api/auth.unit.js
module.js:327
    throw err;
    ^

Error: Cannot find module 'c:\Source\MyProject\node'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:974:3

Mocha exited abnormally with code 1 at Tue Sep 27 15:13:46

node.exe is in my windows $PATH.

I then tried setting mocha-which-node, with and without an escaped path, and I get the same error.

  '(mocha-which-node "C:\\Program\\ Files\\nodejs\\node.exe")
@scottaj
Copy link
Owner

scottaj commented Sep 27, 2016

Where did you set mocha-which-node? Setting it should change the output in the compilation buffer to the path you set it to, did you see that change?

I'm not sure how emacs looks up things on the windows path (I have never used emacs on windows).

@bleggett
Copy link
Author

@scottaj In my .emacs, so yeah would expect it to work, I'm not sure either.

@scottaj
Copy link
Owner

scottaj commented Sep 28, 2016

Can you post the output of the test run buffer after setting that value, so I can see the command it is generating? Are you sure you are setting the variable after the plugin loads so that it is not overriden by the plugin's default?

You may want to try setting the value in the customize UI and see if it sticks then.

@scottaj
Copy link
Owner

scottaj commented Dec 12, 2016

Any update on this? I'll close it otherwise.

@jmhdez
Copy link

jmhdez commented Jan 12, 2017

Same problem here.

I have changed the path of mocha-which-node and I can see the new path in the test buffer, but still not working:

 "c:\Program Files\nodejs\node" node_modules/.bin/mocha --recursive --reporter dot --opts e:/Desarrollo/IGT.POS.WebAdmin/src/WebAdmin/mocha.opts e:/Desarrollo/IGT.POS.WebAdmin/src/WebAdmin/src/app/ui/Login.spec.tsx
module.js:327
    throw err;
    ^

Error: Cannot find module 'c:\Program Files\nodejs\node'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:968:3

Any idea?

@scottaj
Copy link
Owner

scottaj commented Jan 12, 2017

If you copy that command to your CLI, does it work or give the same error? The error you posted is a nodeJS error, not an error from this plugin. This indicates node actually did run. What is weird is that it looks like it tried to run its own executable, and then blew up doing that.

@jmhdez
Copy link

jmhdez commented Jan 12, 2017

I've made it work using the following settings:

((nil . (
            (mocha-which-node . "")
            (mocha-command . ".\node_modules\.bin\mocha.cmd")
            (mocha-environment-variables . "NODE_ENV=test")
            (mocha-options . "--recursive --reporter dot -t 5000")
            (mocha-project-test-directory . "test")
            (mocha-reporter . "spec")
            )))

It looks like in windows it's easier to just run the mocha.cmd command installed with mocha than trying to run the script through node.

Thanks for your help and for this great package :-)

@vidjuheffex
Copy link

@jmhdez any idea how that would translate to 'customize', hoping to avoid having to make a file for every project but have yet to get this package to work unfortunetly

@jmhdez
Copy link

jmhdez commented Jul 20, 2017

@vidjuheffex the simplest way I found to make it work was to set this vars in .emacs.d to run the mocha installed locally in each project using the mocha.opts for that project.

(setq mocha-command ".\\node_modules\\.bin\\mocha.cmd")
(setq mocha-which-node "")

@vidjuheffex
Copy link

Works for me! Strangely the exact same values in customize do not work. I also am not sure what you mean by mocha.opts, but I do know that mocha-text-project is working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants