tern icon indicating copy to clipboard operation
tern copied to clipboard

Can't run on command line in Windows/Cygwin

Open davidmichaelkarr opened this issue 11 years ago • 5 comments

I'd just like to experiment with Tern, and AngularJS customizations. I'm on Win7/Cygwin. I put the "tern/bin" directory in my path, then ran "tern" from a new shell.

I get the following:

module.js:340 throw err; ^ Error: Cannot find module 'C:\c\users\myuid\git\tern\bin\tern' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16)

at node.js:902:3

That translation to "C:\c\users..." is wrong.

Note that if I instead try a more complex command line like this:

node "$(cygpath -m ~/git/tern/bin/tern)"

(If you don't know, "cygpath -m" translates a Cygwin path to a form like "C:/users/...".)

When I run this, I instead get the following:

module.js:340 throw err; ^ Error: Cannot find module 'acorn/acorn' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at exports.toString (C:\Users\dk068x\git\tern\lib\infer.js:17:25) at Object. (C:\Users\dk068x\git\tern\lib\infer.js:22:3) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32)

at Function.Module._load (module.js:312:12)

davidmichaelkarr avatar Mar 26 '14 17:03 davidmichaelkarr

I have no recent experience with cygwin, but this seems like a fundamental misunderstanding between that environment and node. The failure is in basic module loading, which is not Tern-specific at all. I assume you get the same issues when running other node scripts that require other modules. Did you try? If so, I suspect reporting this to the node (or even cygwin) projects is more productive.

marijnh avatar Mar 26 '14 17:03 marijnh

I use this same Node installation to run Karma for javascript unit tests, both on the command line, and from a Maven build script, both from a Cygwin shell.

davidmichaelkarr avatar Mar 26 '14 17:03 davidmichaelkarr

Interesting. Still, the module is there, obviously (the file exists, and is a JavaScript program), so something is going wrong when resolving the path to the script — and there Tern doesn't do anything non-obvious... it just calls require with a relative path.

marijnh avatar Mar 28 '14 21:03 marijnh

@davidmichaelkarr For node scripts on Cygwin, I exclusively call them like cmd /c tern. Elimininates most issues, and I'd advice to alias it if it works for you.

silverwind avatar Jan 17 '15 17:01 silverwind

try this solution

https://github.com/npm/npm/issues/2465#issuecomment-6157373

samzeng avatar May 08 '17 09:05 samzeng