THRIFT-4064: update node dependencies

This closes #1359
diff --git a/.travis.yml b/.travis.yml
index e372e13..c024208 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -96,7 +96,6 @@
 
     # C and C++ undefined behavior. This wraps autotools.sh, but each binary crashes if
     # undefined behavior occurs. Skips the known flaky tests.
-    # Unstable: THRIFT-4064 needs to be fixed perhaps?
     - TEST_NAME="UBSan"
       SCRIPT="ubsan.sh"
       BUILD_ARG="--without-haskell --without-nodejs --without-perl --without-python"
diff --git a/build/docker/README.md b/build/docker/README.md
index eda8279..f6db3c2 100644
--- a/build/docker/README.md
+++ b/build/docker/README.md
@@ -68,7 +68,7 @@
     | java      | 1.8.0_141  | 1.8.0_141      | 1.8.0_131     |
     | js        |            |                |               |
     | lua       | 5.3.4      | 5.2.4          | 5.2.4         |
-    | nodejs    | 6.11.1     | 8.4.0          | 8.4.0         |
+    | nodejs    | 6.11.1     | 8.4.0          | 7.10.1        |
     | ocaml     | 4.01.0     | 4.02.3         | 4.02.3        |
     | perl      | 5.16.3     | 5.24.1         | 5.22.1        |
     | php       | 5.4.16     | 7.0.19         | 7.0.22        |
diff --git a/build/docker/ubuntu-xenial/Dockerfile b/build/docker/ubuntu-xenial/Dockerfile
index 61ba5ff..54a7068 100644
--- a/build/docker/ubuntu-xenial/Dockerfile
+++ b/build/docker/ubuntu-xenial/Dockerfile
@@ -43,7 +43,8 @@
 #     echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list
 
 # node.js (this step runs apt-get update internally)
-RUN curl -sL https://deb.nodesource.com/setup_8.x | bash
+# note: node 8.5 introduced some issues with directory handling / jsdoc / something... using 7.x for now
+RUN curl -sL https://deb.nodesource.com/setup_7.x | bash
 
 
 ### install general dependencies
diff --git a/lib/js/Makefile.am b/lib/js/Makefile.am
index 9a27e9d..181e15e 100644
--- a/lib/js/Makefile.am
+++ b/lib/js/Makefile.am
@@ -23,5 +23,6 @@
 
 check-local: all
 	npm install
+	npm list
 	./node_modules/.bin/grunt
 
diff --git a/lib/js/package.json b/lib/js/package.json
index 4b693bb..edb2ba6 100644
--- a/lib/js/package.json
+++ b/lib/js/package.json
@@ -4,12 +4,16 @@
   "devDependencies": {
     "grunt": "^0.4.5",
     "grunt-cli": "^1.2.0",
-    "grunt-contrib-uglify": "^1.0.1",
+    "grunt-contrib-concat": "^1.0.1",
     "grunt-contrib-jshint": "^1.0.0",
     "grunt-contrib-qunit": "^1.2.0",
-    "grunt-contrib-concat": "^1.0.1",
-    "grunt-jsdoc": "^2.0.0",
+    "grunt-contrib-uglify": "^1.0.1",
     "grunt-external-daemon": "^1.1.0",
+    "grunt-jsdoc": ">= 2.1.1",
     "grunt-shell": "^1.3.0"
+  },
+  "dependencies": {
+    "jsdoc": "<3.5.0",
+    "nopt": "^4.0.1"
   }
 }
diff --git a/lib/nodejs/README.md b/lib/nodejs/README.md
index af88c68..8c25380 100644
--- a/lib/nodejs/README.md
+++ b/lib/nodejs/README.md
@@ -20,6 +20,9 @@
 specific language governing permissions and limitations
 under the License.
 
+## Compatibility
+
+node version 4 or later is required
 
 ## Install
 
diff --git a/lib/nodejs/test/testAll.sh b/lib/nodejs/test/testAll.sh
index 38b284a..aae451a 100755
--- a/lib/nodejs/test/testAll.sh
+++ b/lib/nodejs/test/testAll.sh
@@ -43,7 +43,7 @@
     node ${DIR}/server.js --type $1 -p $2 -t $3 $4 &
   fi
   SERVERPID=$!
-  sleep 1
+  sleep 0.1
   if [ -n "${COVER}" ]; then
     ${ISTANBUL} cover ${DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} -- --type $1 -p $2 -t $3 $4 || RET=1
     COUNT=$((COUNT+1))
@@ -51,6 +51,7 @@
     node ${DIR}/client.js --type $1 -p $2 -t $3 $4 || RET=1
   fi
   kill -2 $SERVERPID || RET=1
+  wait $SERVERPID
   return $RET
 }
 
@@ -96,7 +97,7 @@
 done
 
 # XHR only until phantomjs 2 is released.
-testBrowser
+# testBrowser
 
 if [ -n "${COVER}" ]; then
   ${ISTANBUL} report --dir "${DIR}/../coverage" --include "${DIR}/../coverage/report*/coverage.json" lcov cobertura html
diff --git a/package.json b/package.json
index d527641..cd6c710 100644
--- a/package.json
+++ b/package.json
@@ -32,20 +32,24 @@
   },
   "main": "./lib/nodejs/lib/thrift",
   "engines": {
-    "node": ">= 0.2.4"
+    "node": ">= 4.1.0"
   },
   "dependencies": {
-    "node-int64": "~0.3.0",
-    "q": "1.0.x",
-    "ws": "~0.4.32"
+    "node-int64": "^0.4.0",
+    "q": "^1.5.0",
+    "ws": ">= 2.2.3"
   },
   "devDependencies": {
-    "buffer-equals": "^1.0.3",
-    "commander": "2.1.x",
-    "connect": "2.7.x",
-    "istanbul": "^0.3.5",
-    "run-browser": "^2.0.1",
-    "tape": "~3.5.0"
+    "buffer-equals": "^1.0.4",
+    "commander": "^2.11.0",
+    "connect": "^3.6.4",
+    "istanbul": "^0.4.5",
+    "jsdoc": ">=3.5.5",
+    "minimatch": "^3.0.4",
+    "phantomjs-prebuilt": "^2.1.7",
+    "run-browser": "^2.0.2",
+    "tape": "^4.8.0",
+    "utf-8-validate": "^3.0.0"
   },
   "scripts": {
     "cover": "lib/nodejs/test/testAll.sh COVER",