Emacs / Tern interaction problems

106 views
Skip to first unread message

Robert Inder

unread,
Dec 16, 2014, 5:07:20 PM12/16/14
to tern...@googlegroups.com
Working on WIndows 7, with Emacs 24.2.1, I have two problems.

I've used
    npm install -g tern
to install tern, and now from a command prompt in my (test) project directory...
    node --version
    v010.33
    tern
    Listening on port 51706

And when I go to the place where it has been installed,
    node bin\test
    Ran 392 tests from 73 files.
    All passed.

So far, so good.  But

PROBLEM 1
If I try to invoke tern functionality from within Emacs, I get an error:
    module.js:340
        throw err;
              ^
    Error: Cannot find module 'Y:\.....\js\tern'
        at Function.Module._resolveFilename (module.js:338:15)
        at Function.Module._load (module.js:200:25)
        at Function.Module.runMain (module.js:497:10)
        at startup (node.js:119:16)
        at node.js:906:3

I get the same error if I try "node tern" from the command line.  What is going on here?
Should I be trying to make "
node tern" work, or getting emacs to start tern in the way that works?

PROBLEM 2
I've tried modifying tern-command in  tern.el to use the absolute path for the tern script that npm created (i.e. "...AppData/Roaming/npm/tern")

When I do that, using tern from within emacs seems to start a tern server. 
Certainly it creates a .tern-port file containing a port number. 

But it usually doesn't actually do anything useful.
Usually I just get messages like...
    Request failed: ((error http 400) . TernError: No expression at the given position.)

I get this from, for instance M-. or C-c C-d when the cursor is in the name of a function, or on either the opening or closing parenthesis.

I also sometimes get
    Making url-show-status local to  *http 127.0.0.1:51867* while let-bound!
though I only see that in *Messages*.  And
    open-network-stream: make client process failed: connection refused, :name, 127.0.0.1, :buffer, #<killed buffer>, :host, 127.0.0.1, :service, 52299, :nowait, nil

How do I start to debug these things?  Is there a way to monitor the interaction between emacs and tern?  Or get the tern server to log what it is doing?

Robert.









Marijn Haverbeke

unread,
Dec 16, 2014, 5:19:20 PM12/16/14
to Robert Inder, tern-dev
Are you loading tern.el from the files that npm install pulled in? I
have not actually tried to globally install tern like that, but I'm
not sure why it would break. You could try pasting the piece of elisp
that tries to initialize tern-command into *scratch* and poke at it to
see why it is producing such a weird path (does 'Y:\.....\js\tern'
even mean anything?)

You can manually start the server with the --verbose flag (from your
project directory), which will cause it to spit all requests and
responses to stdout. That might shed some light on the situation.
Reply all
Reply to author
Forward
0 new messages