Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

JsHint broke on Sublime Text 2 #33

Closed
lifeinafolder opened this Issue · 23 comments

8 participants

@lifeinafolder

Error I am getting on build:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module './../lib/cli'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/jshint/bin/hint:2:1)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Array.0 (module.js:479:10)
[Finished in 0.1s with exit code 1]
@uipoet
Owner

Bummer. I'll take a look after work today.

@cointilt

Broken on mine for Sublime Text 2 as well.

[Errno 2] No such file or directory
[cmd:  [u'node', u'/Users/willayers/Library/Application Support/Sublime Text 2/Packages/Sublime-    JSHint/scripts/run.js', u'application.js', u'browser: true', u'v8: true', u'es5: true', u'esnext: true', u'globalstrict: true', u'strictundef: true', u'laxradix: true', u'trailing: true', u'undef: false', u'sub: true']]
@bautistaI

This is what I get on mine:

[Errno 2] No such file or directory
[cmd: [u'jshint', u'/Users/IB/Desktop/Email/index.html', u'--reporter', u'/Users/IB/Library/Application Support/Sublime Text 2/Packages/JSHint/reporter.js']]
[dir: /Users/IB/Desktop/Email]
[path: /usr/local/bin:/opt/local/bin]
[Finished]

@cointilt

@bautistaI I had fixed this but I can not remember how. When does this happen for you?

@bautistaI
@bautistaI
@cointilt

I don't see a video

@bautistaI
@cointilt

Did you installe Node via homebrew?

@cointilt

Ok, found the solution. So the way this is developed you have to manually go in and fix the path in the build file.

In a terminal window type this:
which jshint

copy the path without the jshint in it. It should look something like this:
/usr/local/share/npm/bin

Then open up the file named JSHint.sublime-build located in the folder ~/Library/Application Support/Sublime Text 2/Packages/JSHint

On line 10 add the above path you copied to the "path" value like the following:

"osx": {
    "path": "/usr/local/share/npm/bin:/usr/local/bin:/opt/local/bin"
},

After you save this file you can immediately run cmd + j on the file again.

I hope this helps.

@cointilt cointilt referenced this issue from a commit in cointilt/sublime-jshint
@cointilt cointilt Fixes a problem with Sublime Text 2 on Mac
This fixed an issue that was not allowing the build when hitting `cmd` + `j` on Sublime Text 2 for Mac.

Related to issue #33 as well as closed issues #12 and #14.
571f91f
@lifeinafolder

One point of confusion is that there are two packages listed in ST2 Package Manager:
1) JSHint
2) Sublime-JSHint

The original error I reported is on package (1). Now I believe this discussion is around package (1) too.

Now which jshint on my box gives the path /usr/local/bin/jshint and the JSHint.sublime-build file mentioned looks like this on my box:

{
  "selector": "source.js",

  "cmd": ["jshint", "$file", "--reporter", "$packages/JSHint/reporter.js"],

  "file_regex": "file:(.+)\\]",
  "line_regex": "(\\d+),(\\d+)",

  "osx": {
    "path": "/user/local/share/npm/bin:/usr/local/bin:/opt/local/bin"
  },

  "windows": {
    "cmd": ["jshint.cmd", "$file", "--reporter", "$packages\\JSHint\\reporter.js"]
  }
}

So that path is already there in it yet still it doesn't work and I get the original error mentioned by me.

@bautistaI
@cointilt

@bautistaI did you run this command npm install -g jshint

@cointilt

@lifeinafolder the correct package is option 1 JSHint

I got confused by that the first time as well. Just make sure the match up the url under the name with this repo if you are not sure.

@lifeinafolder

@cointilt I did install option 1. But as mentioned in my previous message, it still doesn't work even when the path in my build file is fine.

@cointilt

@lifeinafolder did you install node via homebrew and then jshint via npm?

@lifeinafolder

Not sure if I installed node via homebrew. Jshint was installed via npm for sure.

Is that going to cause an issue?

@cointilt

Try installing it via homebrew and see if that works.

@uipoet
Owner

As the README says, jshint installed via npm should work out of the box for Macintosh and Windows. For Linux, you'll need to also make sure that the path to the jshint binary has been added to your environment's $PATH.

I have just installed a clean version on Macintosh and Linux to confirm things are working as expected and are. There are several questions wrapped up in this single thread so I'm going to close and suggest you open a new more specific issue, if that is indeed the case.

@uipoet uipoet closed this
@stevematdavies

The above solutions do not fix the error on Linux (Ubuntu 14:04) sublimeText 2

@jac1013

I solved this problem in Linux Mint 17 for ST2 with:

sudo npm install jshint -g

@fox94610

Pictures might help
Path to non-Sublime jshint program will vary
Path to node will vary
I couldn't figure what :/opt/local/bin is, since it does not exist on my computer, even so jshint package works in sublime for me now.

paths1
paths2
paths3
paths4
paths5

@goramm

For Ubuntu 14.04 and Sublime 3

Find node path with which node (output: /usr/bin/node)

Find jshint path with which jshint (output: /home/username/local/bin/jshint)

Locate JSHint.py with locate JSHint.py

Add following condition in JSHint.py
elif sublime.platform() == "linux":
args['path'] = "/usr/bin/:/home/username/local/bin/"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.