Skip to content


Subversion checkout URL

You can clone with
Download ZIP


fix runtime.js fs error #543

wants to merge 1 commit into from

6 participants


runtime.js require('fs') is not defined



If runtime.js is meant for the client, why is this here?

edit: Oh, I see issue #611 now. Also, this patch is to /runtime.js instead of /lib/runtime.js. Should both be in version control?

tj commented

yeah it's used for server-side jade as well, ideally we would compile it out but for now im fine with adding ./runtime.js to the repo

tj commented

This issue has been inactive for over 1 month so I'm closing it. If you think it's still an issue re-open. - tjbot

@tj tj closed this

I meant runtime.js is for browser side


I don't have permission to reopen it

@tj tj reopened this

Confirming this is still a problem. Any reason to not just check if this is on a client and not try to find context?


Just came across this today; took a slightly different approach. I try/caught the require() instead of if (node) {} junk.

See pull #734 for the solution.

tj commented

@coderanger yeah it could be as simple as an if, I just dont have time ATM


This would need rebasing, we do need to have a closer look at client/runtime.js issues though, so someone could open a fresh issue if there isn't one already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 19, 2012
  1. @guileen

    fix runtime.js fs error

    guileen authored
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 17 deletions.
  1. +2 −17 runtime.js
19 runtime.js
@@ -96,28 +96,13 @@ exports.escape = function escape(html){
exports.rethrow = function rethrow(err, filename, lineno){
if (!filename) throw err;
- var context = 3
- , str = require('fs').readFileSync(filename, 'utf8')
- , lines = str.split('\n')
- , start = Math.max(lineno - context, 0)
- , end = Math.min(lines.length, lineno + context);
- // Error context
- var context = lines.slice(start, end).map(function(line, i){
- var curr = i + start + 1;
- return (curr == lineno ? ' > ' : ' ')
- + curr
- + '| '
- + line;
- }).join('\n');
// Alter exception message
err.path = filename;
err.message = (filename || 'Jade') + ':' + lineno
- + '\n' + context + '\n\n' + err.message;
+ + '\n\n' + err.message;
throw err;
return exports;
Something went wrong with that request. Please try again.