Closed sindresorhus closed 11 years ago
Ouch. I haven't seen that in my own testing, and don't see it with your example:
function foo() {
return 'bar';
}
// > undefined
console.log(foo());
// > bar
// > undefined
Can you tell me the output of node -v
on your system?
(BTW thanks for reporting this!)
v0.10.11
Works fine in the Node REPL
Same here:
var doubleIt = function(num) {
return num * 2;
// > Execution timed out.
}
doubleIt(2);
Node v0.10.2
Thanks. I really want to get to the bottom of this, but at present I can't reproduce it. Anything you can provide which will help me to get this result (OS, ST version, ???) would be greatly appreciated.
It looks like pexpect is hanging waiting for a prompt before it sends the next line to node. The relevant selection of the config is:
"JavaScript": {
"cmd": "node -e \"require('repl').start('node> ')\"",
"prompt": ["node> ", "\\.\\.+ "]
}
So we run node with a custom prompt then look for that prompt, or a run of dots (which is what is shown when inside a {}
block.)
What prompt do you see in the node REPL when you are inside the body of the function?
Weirdly, @sindresorhus's example works for me, though:
function foo() {
return 'bar';
}
// > undefined
console.log(foo());
// > bar
// > undefined
OSX 10.8.3 Sublime 2.0.1 build 2217
Wait. It's all working fine now? I didn't change anything. Same document, just re-pasted what I copied into here.
Thanks Dan. That's nuts. I'm glad to hear it's working now, but it sounds like there's definitely a bug here. Please post if you find anything else.
Idk, it's timed out again. In the node repl, it looks like this:
> var doubleIt = function(num) {
... return num * 2;
... }
undefined
> doubleIt(2);
4
>
I don't know if this is related to this bug –if not i apologize– but, when i try to run any javascript code line i get this error inside the sublime interpreter:
Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
File "./worksheet.py", line 101, in run
File "./worksheet.py", line 19, in run
File "./repl/repl.py", line 8, in get_repl
File "./repl/repl.py", line 42, in __init__
File "./repl/pexpect.py", line 429, in __init__
File "./repl/pexpect.py", line 516, in _spawn
repl.pexpect.ExceptionPexpect: The command was not found or was not executable: node.
And obviously node
works inside the terminal.
With Ruby it works.
I have OSX 10.8.4 and ST 2.0.1, build 2217. Thanks,
Luca
I have the same issue.
The NodeEval plugin works as expected, returning 7.
var x = 5;
// > undefined
function add_two(num) {
return (num + 2);
// > Execution timed out.
}
add_two(x);
This issue aside, awesome plugin - thanks for your work!
@CarettaCaretta - that sounds like a different bug. Can you please open a new issue for it? Thanks very much.
OK I got it: it's tabs. The workaround is to indent with spaces but I know noone is going to be happy with that, so I guess I'll substitute them before sending to the REPL. Thanks to everyone who reported this; I had no idea.
There's a new tag - 0.7.2 - which should fix this. Not sure how long that will take to flow through to Package Control.
Bizarre. Thanks for the update.
This JS code stop evaluating on the return statement.