Skip to content

Commit a28edd3

Browse files
committed
fix node.js server startup
1 parent 33185ed commit a28edd3

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

mathics/layout/client.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# Your installation of nodejs with the following packages: mathjax-node svg2png (install them using
55
# npm).
66

7-
# Tips for installing nodejs on OS X:
8-
# see https://gist.github.com/DanHerbert/9520689
9-
# export NODE_PATH=/your/path/to/homebrew/bin/node_modules:$NODE_PATH
7+
# Tips for troubleshooting:
8+
# https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
9+
# export NODE_PATH=$(npm root --quiet -g)
1010

1111
import subprocess
1212
from subprocess import Popen
@@ -162,7 +162,7 @@ def _create_client(self):
162162
server_path = os.path.join(
163163
os.path.dirname(os.path.realpath(__file__)), 'server.js')
164164

165-
if True:
165+
if False:
166166
# fixes problems on Windows network drives
167167
import tempfile
168168
fd, copied_path = tempfile.mkstemp(suffix='js')
@@ -172,7 +172,8 @@ def _create_client(self):
172172
server_path = copied_path
173173

174174
def abort(message):
175-
error_text = 'Node.js failed to startup %s:\n\n' % server_path
175+
error_text = '\nNode.js failed to start Mathics server.\n'
176+
'You might need to run: npm install -g mathjax-node svg2png\n\n'
176177
raise WebEngineUnavailable(error_text + message)
177178

178179
process = Popen(
@@ -192,7 +193,7 @@ def abort(message):
192193
error += ' ' + line
193194

194195
process.terminate()
195-
abort(error + '\nPlease check Node.js modules and NODE_PATH')
196+
abort(error)
196197

197198
port = int(status[len(hello):])
198199
except OSError as e:

mathics/layout/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// to install: npm install mathjax-node svg2png
1+
// to install: npm install -g mathjax-node svg2png
22

33
try {
44
function server(methods) {
@@ -72,7 +72,7 @@ try {
7272
server.listen(0); // pick a free port
7373
}
7474

75-
var mathjax = require("mathjax-node/lib/mj-single.js");
75+
var mathjax = require("mathjax-node");
7676
mathjax.config({
7777
MathJax: {
7878
// traditional MathJax configuration

0 commit comments

Comments
 (0)