victorporof / Sublime-JSHint

JSHint Gutter for Sublime Text 2 and 3 via node.js
https://github.com/victorporof/Sublime-JSHint
684 stars 71 forks source link

Node.js was not found in the default path, but I have specified it? #35

Open ScottMaclure opened 11 years ago

ScottMaclure commented 11 years ago

In ~/.config/sublime-text-3/Packages/JSHint Gutter/JSHint.sublime-settings

In console:

% which node /usr/local/bin/node

Then in settings:

"node_path": "/usr/local/bin/node",

But I still get the error and the process fails.

Using build 3047 on Linux (Lubuntu).

Any ideas?

zakdances commented 11 years ago

What specifically does the error say?

ScottMaclure commented 11 years ago

2013-09-17-165958_jshint_gutter_node

zakdances commented 11 years ago

Try setting the node_pathin JSHints user settings, not default settings.

ulidtko commented 11 years ago

Hello all!

I'm having troubles with node_path too on Ubuntu, build 3047.

I've installed Node via aptitude install nodejs, so I have the binary (v0.6.19) as /usr/bin/nodejs. Package nodejs-legacy also provides a symlink /usr/bin/node/usr/bin/nodejs. Neither of these works with Sublime-JSHint.

jshint itself is installed via nmp install jshint. What could be the problem?

ulidtko commented 11 years ago

Ok, so apparently this happens because Ubuntu's stock Node.js is too old. The solution is to install a newer Node.js.

But, for the lazy ones like me, here's a patch that makes the plugin work on Ubuntu with Node.js installed from the repo:

diff --git i/scripts/run.js w/scripts/run.js
index 244ac7d..7259907 100644
--- i/scripts/run.js
+++ w/scripts/run.js
@@ -12,6 +12,7 @@
   // Require path and file system utilities to load the jshint.js file.
   var path = require("path");
   var fs = require("fs");
+  fs.existsSync = path.existsSync;

   // The source file to be linted, original source's path and some options.
   var tempPath = argv[2] || "";
victorporof commented 11 years ago

@ulidtko Great catch!

Anyone experiencing this problem, please pull and try again.

orizens commented 10 years ago

works for me. thanks.

ScottMaclure commented 10 years ago

Quick update - just did a quick tweak of JSHint.py to get the plugin to work on my box:

node = "node" if exists_in_path("node") else settings.get("node_path")

node = settings.get("node_path")

Seems that when it finds "node" on my path and sets node to "node", I get problems. Not sure why yet.

Here's some env info:

% echo $PATH /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

% which node /usr/local/bin/node

% node -v v0.10.15

/usr/local/bin % ls -la node -rwxrwxr-x 1 root root 11113912 Aug 15 17:43 node

Edit: Note that I installed node.js via source, not from apt.

thepatrick commented 10 years ago

I'm getting this error after upgrading to Yosemite - PluginUtils.exists_in_path("node") returns true, but PluginUtils.get_output(["node", ...]) fails with exit status 127 (even ["node", "-v"]) does that)

booleanbetrayal commented 9 years ago

@victorporof - +1 for node_path error on Yosemite. Was previously fine on Mavericks install. Workaround here https://github.com/victorporof/Sublime-HTMLPrettify/issues/107#issuecomment-51530117 successfully hacks around the issue.

borivojevic commented 9 years ago

I'm facing the same issue on Yosemite. The workaround @booleanbetrayal mentions works for me as well. I had to hardcode node path in ~/Library/Application Support/Sublime Text 2/Packages/JSHint Gutter/JSHint.py (search for def get_node_path(): method)

Anthonyeef commented 9 years ago

The same issue here. I am using Fedora 21 and the node is manually installed inside my machine. I have update everything in my machine. The which node return usr/bin/node . Any helpful suggestion?

Anthonyeef commented 9 years ago

Wait.... amazing.. I just simply reinstall the plugin and try to set the path in file HTMLPrettify.sublime-settings like this:

"node_path": {
    "windows": "C:/Program Files/nodejs/node.exe",
    "linux": "/usr/bin/node",
    "osx": "/usr/local/bin/node"
  },

and it works :) :+1: really don't know the magic, but it makes sense cause my node path really is there.

codylewis commented 8 years ago

@Anthonyeef, reinstalling did the trick. It's silly how simple it was!

cdrrazan commented 6 years ago

Same problem, ubuntu 17.04. However, following did the work not sure if it is right one. which node returned the path ~/.nvm/versions/node/v9.1.0/bin/node. So replaced with the default path in the configuration and voila it seemed to work.

abhishekdam commented 3 years ago

Wait.... amazing.. I just simply reinstall the plugin and try to set the path in file HTMLPrettify.sublime-settings like this:

"node_path": {
    "windows": "C:/Program Files/nodejs/node.exe",
    "linux": "/usr/bin/node",
    "osx": "/usr/local/bin/node"
  },

and it works :) +1 really don't know the magic, but it makes sense cause my node path really is there.

yup this now worked for me.