From 13b0ca6b2afc1bae46f6757425e54e97b087ba9f Mon Sep 17 00:00:00 2001 From: Romain Petit Date: Tue, 6 Nov 2018 15:56:17 +0100 Subject: [PATCH] Don't detect nw.js as node.js nw.js is chrome plus nodejs. It will succeed everywhere chrome succeeds, but fail in many cases where nodejs succeeds (see issue 9071). So it's safer to consider it as a browser context rather than a nodejs context. Make travis happy again CS Readability + Explanation The relevant portion of the NW.js documentation: http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/#access-nodejs-and-nwjs-api-in-browser-context Added full link to relevant doc. --- src/shared/is_node.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shared/is_node.js b/src/shared/is_node.js index 1ab845300..937438662 100644 --- a/src/shared/is_node.js +++ b/src/shared/is_node.js @@ -15,5 +15,9 @@ /* globals module, process */ module.exports = function isNodeJS() { - return typeof process === 'object' && process + '' === '[object process]'; + // NW.js is a browser context, but copies some Node.js objects; see + // http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/#access-nodejs-and-nwjs-api-in-browser-context + return typeof process === 'object' && + process + '' === '[object process]' && + !process.versions['nw']; };