hallettj / jslint.vim

VIM plugin and command line tool for running JSLint <http://jslint.com/>. This is project is no longer under active development. See Readme for details.
Other
463 stars 132 forks source link

Vim(echoerr): could not invoke JSLint #13

Open ivanshaovchev opened 13 years ago

ivanshaovchev commented 13 years ago

Hi,

I am getting this error ( the one in the title ) when I try to open a .js file. In addition I get:

Error detected while processing function 87_JSLint: Line 33: could not invoke JSLint!

I am running Ubuntu 10.04. I am using jslint.vim_0.7. I have installed it with rake install. I have installed both node and spidermonkey.

marcindomanski commented 13 years ago

Hi,

I think I am getting the same error, although the message is a little different. Vim complains about function 37_JSLint: and also says: "could not invoke JSLint!", pointing at row 40.

I am on Ubuntu 10.10, have vim 7.2.330 (with filetype plugin on in my .vimrc) and trying to use jslint.vim with nodejs, which I installed from the nodejs package.

One note though - the plugin didn't seem to work with nodejs out of the box, it couldn't find any JS interpreters. So I looked at the code and made one modification in lines 68 and 69 where it searches for the nodejs interpreter. Not sure if that's correct, but after installing nodejs from the package, the binary is called nodejs, whereas your plugin uses 'node' as the nodejs binary. After that change, however, it is still complaining with the above message.

Any ideas what might be causing this?

As far as my nodejs is concerned, it seems to work just fine. I can run it from the command line.

Thanks

blackrobot commented 13 years ago

I too am having this exact issue.

leppert commented 13 years ago

I'm having this problem using MacVim with the Janus collection of vim goodies. Started when I upgraded from OS X 10.6 (Snow Leopard) to OS X 10.7 (Lion).

First error on file open:

"example.js" [readonly][noeol] 7L, 337C
Vim(echoerr):could not invoke JSLint!

Second error while cursing around the file:

Error detected while processing function <SNR>71_JSLint:
line   40:
could not invoke JSLint!  
CRIZN commented 13 years ago

I too am in the same situation as formasfunction... using OS X lion golden master with macvim + janus.

hukl commented 13 years ago

+1 macvim / osx / janus

hukl commented 13 years ago

my "hotfix" is to uncomment lines 155-159 in /.vim/ftplugin/javascript/jslint.vim because other than the warning - the plugin seems to work just fine

CRIZN commented 13 years ago

hukl, all that fix seems to do is disable the error message. Syntax highlighting doesn't appear to be working for me.

CRIZN commented 13 years ago

So I got this monkey patched to work by commenting out lines 66 & 67 in jslint.vim that reference the use of JSC. This only works because I have node installed and it is now using that to handle the js.

Looks like something may have changed with JSC in OS X 10.7 that isn't playing nicely.

hukl commented 13 years ago

i have echo'ed the command and pasted it to the shell and it executed just fine without an error. the if clause in #155 returned an error code of 3 which doesn't make any sense so I've commented it out since the plugin worked otherwise for me.

hukl commented 13 years ago

but yeah - a real fix would be awesome :)

mafolz commented 13 years ago

this error just say, that the command to execute the js doesn't work like expected. Just look at line 154.

  let b:jslint_output = system(s:cmd, lines . "\n")
  if v:shell_error
    echoerr b:jslint_output
    echoerr 'could not invoke JSLint!'
    let b:jslint_disabled = 1
  end

if you echo the error from the command with

    echoerr b:jslint_output

you can se what happen. in my case there could detect nodejs but couldn't found them to execute.

thegrubbsian commented 13 years ago

Is this issue solved by using 7.3 snapshot 59 on OSX Lion?

VGraupera commented 13 years ago

I dont think so, I just installed snapshot 59 and hit this same issue on Lion

eventualbuddha commented 13 years ago

If you prefer not to edit the jslint.vim plugin and have node installed you can add this to your .vimrc: let $JS_CMD='node'.

CRIZN commented 13 years ago

Much cleaner, thanks for the tip On Jul 21, 2011, at 10:25 AM, eventualbuddha wrote:

If you prefer not to edit the jslint.vim plugin and have node installed you can add this to your .vimrc: set $JS_CMD='node'.

Reply to this email directly or view it on GitHub: https://github.com/hallettj/jslint.vim/issues/13#issuecomment-1625219

VGraupera commented 13 years ago

When I added this to my .vimrc.local I got "E518: Unknown option: $JS_CMD='node'". ?

eventualbuddha commented 13 years ago

Whoops! Updated my previous comment to be correct. Here's what I have in my .vimrc:

" Use Node.js for JavaScript interpretation
let $JS_CMD='node'
trobrock commented 13 years ago

the let $JS_CMD does not solve the problem for me, using regular terminal vim and Lion, without janus

eventualbuddha commented 13 years ago

@trobrock: Do you actually have node installed and in your $PATH?

trobrock commented 13 years ago

Yes i do: which node gives: /usr/local/bin/node

On Tue, Jul 26, 2011 at 10:27 AM, eventualbuddha reply@reply.github.com wrote:

@trobrock: Do you actually have node installed and in your $PATH?

Reply to this email directly or view it on GitHub: https://github.com/hallettj/jslint.vim/issues/13#issuecomment-1656134

Thanks, Trae Robrock http://trobrock.com

jackdempsey commented 13 years ago

eventualbuddha's fixed it for me (janus on Lion)

abelmartin commented 13 years ago

@csexton's pull request fixes the issue on my Mac running 10.7. His solution was to update jslint-core.js with Douglas Crockford's latest revision. Check it out here: https://github.com/csexton/jslint.vim/commit/7405f3bdee89f290c9126caf649cdd49caa9528f

mrkschan commented 13 years ago

ubuntu 10.10, using spidermonkey ... same problem. subscribe to this issue.

mrkschan commented 13 years ago

Patched with latest jslint as @abelmartin mention Following @mafolz tips, found the problem... My problem was related to having space character in the s:cmd.

My s:cmd was - cd /home/kschan/Ubuntu One/vim/ftplugin/javascript/jslint/ && js /home/kschan/Ubuntu One/vim/ftplugin/javascript/jslint/runjslint.js

As you may notice, I use Ubuntu One to sync my vim plugins across ubuntu installations :S BTW, I just modified s:cmd as the following and it works. let s:cmd = 'cd "' . s:plugin_path . '" && ' . s:cmd . ' "' . s:plugin_path . '"runjslint.' . s:runjslint_ext

abelmartin commented 13 years ago

Glad I could help :)

VAggrippino commented 13 years ago

Following through the code in ftplugin/javascript/jslint.vim, I determined that the lines which run the command and generate the error are:

let b:jslint_output = system(s:cmd, lines . "\n")
if v:shell_error
    echoerr 'could not invoke JSLint!'
    let b:jslint_disabled = 1
end

On my system s:cmd is node.js 0.2.6 (0.2.6-4ubuntu1).

So, the command-line equivalent of what was actually executed is:

cat myfile.js | node runjslint.js

And this produced the actual error that causes the problem:

.vim/ftplugin/javascript/jslint/runjslint.js:73
    var ok = JSLINT(body, {indent: 2})
             ^
TypeError: Property 'JSLINT' of object #<an Object> is not a function
    at /home/ghodmode/.vim/ftplugin/javascript/jslint/runjslint.js:73:14
    at Stream.<anonymous> (/home/ghodmode/.vim/ftplugin/javascript/jslint/runjslint.js:28:31)
    at Stream.emit (events:28:17)
    at IOWatcher.callback (net:471:53)
    at node.js:773:9

In runjslint.js, I found where the JSLINT object should be defined right at the top:

if (typeof require != 'undefined') {
    JSLINT = require('./jslint-core').JSLINT;
    print = require('sys').puts;
} else {
    load('jslint-core.js');
}

... but I didn't know exactly what require should return, so I looked at my nodejs documentation in /usr/share/doc/nodejs/api.html and found the important details under the "Modules" section:

To export an object, add to the special exports object. (Alternatively, one can use this instead of exports.)

So, the solution was to use this exports object in the jslint.vim copy of JSLint : ftplugin/javascript/jslint/jslint-core.js:

var JSLINT = (function () {
// ...
    return itself;

}());

exports.JSLINT = JSLINT;

I'm pretty sure that this is the actual cause of the problem for me. What I don't get is how it broke.

I cloned hallettj/jslint.vim.git, but the most recent commit in my clone was from @csexton. That was where he updated the jslint-core.js to Crockford's latest ...

changeset: 108:65918308e036 parent: 97:41488d2c2055 user: Christopher Sexton date: Thu Jul 21 11:00:10 2011 -04000 summary: Updated jslint-core.js to Crockford's latest

This doesn't match the latest version of the repo available through GitHub's web interface and @csexton isn't even listed as a contributor. I didn't even know about @csexton's fork until I read this thread.

Looking at the current version of jslint-core.js in the web version of the repo, I see 152 lines of code at the end designed to make it work with node.js. So, that's what I'm going to add to my version.

Ghodmode http://www.ghodmode.com/blog

csexton commented 13 years ago

Maybe next time leave my email out of the ticket :-) I know it's in the commit history and all, but it'd be nice to to put it in these comments.

I can confirm, when I run vim this way: JS_CMD=node vim, using my branch of jslint, I get our old pal could not invoke JSLint!

So following your comments, I added the exports stuff to the end of the file and I can get it to run, but I get lint warnings about nearly every line. Seems that it is not using the setting properly from jslintrc or that jslint-run passes in.

Not being all the familiar with node, not sure what is going on here. But I did spend some time trying to work with how the require would work -- and hoping to come up with a way to be able to use Crockfords jslint.vim verbatim with this plugin. Seems like the right way to do it.

FWIW, when I do a fresh clone of https://github.com/hallettj/jslint.vim.git the most recent commit I see is:

 8605dd8  (HEAD, origin/master, origin/HEAD, master) Specify very-magic mode for regular expressions. Jesse Hallett 6 months ago
VAggrippino commented 13 years ago

I'm sorry about the email address. That wasn't intentional. I was just copying and pasting everything that seemed relevant and I didn't look carefully enough. I've already edited my post and removed the email address.

Now that I look more closely, I'm seeing the errors on nearly every line, too. I wonder if @hallettj further modified his copy of JSLint so that it would work well with jslint.vim and node. I can't find a copy of Crockford's jslint.js that matches to do a diff because GitHub's history of the file doesn't go back that far.

I agree that it would be better to use an unmodified version of Crockford's jslint.js and I'm sure there must be a way. I'm not familiar with node (or the other JS engines) either. I only installed it to support jslint.vim and this is the first time I've even looked at the documentation.

For now, I'm going to revert back to @halletj's version because I've been using this successfully for a while and it has made my coding much better.

I discovered that my clone issue is because I used Mercurial's hg-git plugin rather than using Git directly. I thought it should be the same, but when I use Git directly, I see the same most recent commit that you do.

jessesanford commented 13 years ago

The fix for me on the mac was simply to make sure that JS_CMD was setup to use node. I added it to my bashrc and zshrc and things worked fine. Using 10.6.8 and node .4.11

daveok commented 13 years ago

I'm on Mac OSX 10.6.8, and as far as I can tell this error started happening after I did an OS software update. Can't tell you what exactly did it, sadly. I'm just gonna switch to using node in place of whatever the now broken default is on OSX. Thanks for all info in this thread, hope the issue gets a resolution.

dfucci commented 12 years ago

Getting the same problem on MacOSX 10.7, MacVim-snapshot 61, node 0.4.1 Fixed substituting the jslint-core.js with the one here https://raw.github.com/douglascrockford/JSLint/master/jslint.js

wmertens commented 12 years ago

I too managed to make it work on 10.7 by pulling the latest jslint-core.js

lawrencegs commented 12 years ago

Mine stop working with the latest (2012-01-25) version. Same error:

TypeError: Property 'JSLINT' of object #<Object> is not a function
    at /Users/lawrencegs/.vim/ftplugin/javascript/jslint/runjslint.js:73:14
    at [object Object].<anonymous> (/Users/lawrencegs/.vim/ftplugin/javascript/jslint/runjslint.js:28:17)
    at [object Object].emit (events.js:64:17)
japrogramer commented 12 years ago

mine stopped working with the latest git build of node, i also installed jslint with npm but didn't fix error does jslint.vim use its own ? if so why ? hope this gets fixed soon

vohtaski commented 12 years ago

same problem and snow leopard 10.6.8, suggested updating jslint-core.js fixed the problem

hallettj commented 12 years ago

There seem to be some different issues here in different environments. I'm seeing what I can do to address all of them. To summarize:

So if you have been having problems with jslint.vim, the latest version may have a fix for your problem. In case it doesn't, I included the change that @mafolz suggested which will output a more detailed error message if something goes wrong. If you try the latest jslint.vim version and continue to have problems, I would appreciate it if you could post that more detailed error output here.

The errors that jslint.vim outputs might go by too fast for you to copy them down. You can use the vim command :messages to bring them back.

hallettj commented 12 years ago

@japrogramer, jslint.vim does bundle its own copy of JSLint. I wrote the plugin before npm existed; and I am trying to support a few different environments where npm may not be available. Going all node with a future version and tying into npm could be a good idea though.

tingham commented 12 years ago

This is on a CentOS 5.8 box with node.js installed.

"Minnow/Minnow.js" 17L, 346C Error detected while processing function 19JSLint: line 73: E117: Unknown function: matchadd E15: Invalid expression: matchadd('JSLintError', '\v%' . l:line . 'l\S.(\S|$)') E117: Unknown function: matchadd E15: Invalid expression: matchadd('JSLintError', '\v%' . l:line . 'l\S.(\S|$)') E117: Unknown function: matchadd E15: Invalid expression: matchadd('JSLintError', '\v%' . l:line . 'l\S.(\S|$)') E117: Unknown function: matchadd E15: Invalid expression: matchadd('JSLintError', '\v%' . l:line . 'l\S.(\S|$)') E117: Unknown function: matchadd E15: Invalid expression: matchadd('JSLintError', '\v%' . l:line . 'l\S.(\S|$)') E117: Unknown function: matchadd E15: Invalid expression: matchadd('JSLintError', '\v%' . l:line . 'l\S.(\S|$)') E117: Unknown function: matchadd E15: Invalid expression: matchadd('JSLintError', '\v%' . l:line . 'l\S.(\S|$)') E117: Unknown function: matchadd E15: Invalid expression: matchadd('JSLintError', '\v%' . l:line . 'l\S.(\S|$)') E117: Unknown function: matchadd E15: Invalid expression: matchadd('JSLintError', '\v%' . l:line . 'l\S.(\S|$)') E117: Unknown function: matchadd E15: Invalid expression: matchadd('JSLintError', '\v%' . l:line . 'l\S._(\S|$)') E117: Unknown function: matchadd E15: Invalid expression: matchadd('JSLintError', '\v%' . l:line . 'l\S.*(\S|$)')

deju commented 8 years ago

I added let $JS_CMD='node' in .vimrc file and the error disappered.