tanepiper / SublimeText-Nodejs

nodejs snippets and bindings for Sublime Text 3
Do What The F*ck You Want To Public License
1.13k stars 262 forks source link

add env variable 'NODE_PATH' to command runtime #39

Closed y-lan closed 11 years ago

y-lan commented 11 years ago

without 'NODE_PATH' env variable, node wouldn't be able to require modules installed by 'npm -g'

mrchief commented 11 years ago

I get the same

'node' is not recognized as an internal or external command, operable program or batch file.

error. I thought it was ST2 v2.0.2 that broke it.

Getting the older commit works perfectly! :+1:

tssajo commented 11 years ago

I managed to make it work again on Windows 7 by partially reverting a commit in this file:

lib/command_thread.py

I changed this line: shell=shell, universal_newlines=True, env=self.env) to this shell=shell, universal_newlines=True)

I know that it makes the env variable completely unused, but I was unable to fix the issue on my Windows PC any other way... If anyone can come up with a better fix, please let me know! ;)

I hope it helps someone,

Zoltan

tssajo commented 11 years ago

Just to give you guys some more info:

I believe that on Windows, node must be in the system PATH environment variable. Otherwise node.exe (and other node related commands, such as npm.cmd) will not be found and cannot be run by Sublime Text 2. If we provide the shell that we execute our own env variable which does not have the Windows PATH in it then node just won't be found and it won't work. I've tried to set the location of the node.exe file in Nodejs.sublime-settings file but I hade several issues: one of them is the space character found in the path to the standard node installation on Windows: "C:\Program Files...", you just can't seem to specify a path to node.exe in Nodejs.sublime-settings with a space character in the actual path. I overcome this first issue by creating a link with the mklink Windows command to the node installation directory and then I no longer get the "'node' is not recognized" error message. But node was still not working properly. It gave me no output at all. No error messages and no output. At this point I just give up and decided to patch the command_thread.py file as I described in my previous message. This way we no longer provide our own environment to the shell that we launch. This change made node to work again as before.

Zoltan

On 8/26/2013 10:08 PM, Zoltan Frombach wrote:

No, an update to the SublimeText-Nodejs PLUGIN broke it.

I managed to make it work again on Windows 7 by partially reverting a commit in this file:

lib/command_thread.py

I changed this line: shell=shell,universal_newlines=True,env=self.env) to this shell=shell,universal_newlines=True)

I know that it makes the env variable completely unused, but I was unable to fix the issue on my Windows PC any other way... If anyone can come up with a better fix, please let me know! ;)

I hope it helps,

Zoltan

On 8/26/2013 8:38 PM, Hrusikesh Panda wrote:

I get the same

'node' is not recognized as an internal or external command,
operable program or batch file.

error. I thought it was ST2 v2.0.2 that broke it.

— Reply to this email directly or view it on GitHub https://github.com/tanepiper/SublimeText-Nodejs/pull/39#issuecomment-23284963.

tssajo commented 11 years ago

No, an update to the SublimeText-Nodejs PLUGIN broke it.

I managed to make it work again on Windows 7 by partially reverting a commit in this file:

lib/command_thread.py

I changed this line: shell=shell,universal_newlines=True,env=self.env) to this shell=shell,universal_newlines=True)

I know that it makes the env variable completely unused, but I was unable to fix the issue on my Windows PC any other way... If anyone can come up with a better fix, please let me know! ;)

I hope it helps,

Zoltan

On 8/26/2013 8:38 PM, Hrusikesh Panda wrote:

I get the same

'node' is not recognized as an internal or external command,
operable program or batch file.

error. I thought it was ST2 v2.0.2 that broke it.

— Reply to this email directly or view it on GitHub https://github.com/tanepiper/SublimeText-Nodejs/pull/39#issuecomment-23284963.

mrchief commented 11 years ago

I believe that on Windows, node must be in the system PATH environment variable.

Yes, you need to have node in your PATH.

you just can't seem to specify a path to node.exe in Nodejs.sublime-settings with a space character in the actual path.

You can actually. You just need to escape the space character like so: "C:\Program\ Files\..."

But anyway, the older commit works just fine and whatever value this new PR seems to add, is missing anyway on Windows so you're not missing out anything by using the old commit.

Your insights were much helpful, thx!

tssajo commented 11 years ago

You can actually. You just need to escape the space character like so: "C:\Program\ Files..."

No, unfortunately escaping the space character did not work... :(

mrchief commented 11 years ago

I should have said "YMMV" :). I've seen it work for some other plugins. But the rabbit hole goes deeper: https://github.com/kemayo/sublime-text-2-git/issues/41

y-lan commented 11 years ago

@tssajo I guess my last patch ( to add NODE_PATH to runtime environment) broke it in Windows. Will send a pull request to fix it.

tssajo commented 11 years ago

Actually, it got broke since you use a custom env when you run the shell. This line breaks it: shell=shell,universal_newlines=True,env=self.env)