Sublime-JSHint icon indicating copy to clipboard operation
Sublime-JSHint copied to clipboard

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

Open ScottMaclure opened this issue 11 years ago • 16 comments

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?

ScottMaclure avatar Sep 02 '13 02:09 ScottMaclure

What specifically does the error say?

zakdances avatar Sep 07 '13 04:09 zakdances

2013-09-17-165958_jshint_gutter_node

ScottMaclure avatar Sep 17 '13 07:09 ScottMaclure

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

zakdances avatar Sep 17 '13 07:09 zakdances

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 avatar Sep 19 '13 15:09 ulidtko

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] || "";

ulidtko avatar Sep 19 '13 16:09 ulidtko

@ulidtko Great catch!

Anyone experiencing this problem, please pull and try again.

victorporof avatar Sep 23 '13 10:09 victorporof

works for me. thanks.

orizens avatar Sep 25 '13 15:09 orizens

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.

ScottMaclure avatar Oct 16 '13 00:10 ScottMaclure

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)

thepatrick avatar Aug 07 '14 07:08 thepatrick

@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.

booleanbetrayal avatar Oct 17 '14 14:10 booleanbetrayal

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)

borivojevic avatar Oct 22 '14 13:10 borivojevic

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 avatar Feb 28 '15 04:02 Anthonyeef

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.

Anthonyeef avatar Feb 28 '15 04:02 Anthonyeef

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

codylewis avatar Oct 01 '15 23:10 codylewis

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.

cdrrazan avatar Nov 21 '17 01:11 cdrrazan

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.

abhishekdam avatar Jun 12 '21 20:06 abhishekdam