I'd like to use processingJS as an npm package in a nodeJS server for deployment on MS Azure. I'm using VS15. I'm having trouble referencing it:
var pjs = require('processing-js');
var http = require('http'),
fs = require('fs');
var port = process.env.port || 1337;
The first line of my code throws
ReferenceError: navigator is not defined
The research I've done leads me to believe that navigator is some property related to the browser but I'm having trouble finding more information.
I have looked at these resources but wasn't able to come up with a solution:
Require('jquery-ui') in node-webkit produces navigator not found error
https://github.com/tobie/ua-parser/issues/440
http://fredkschott.com/post/2014/06/require-and-the-module-system/
I'd like to be able to precompile processing into javascript.
Thanks in advance.
navigator
is an object available in a desktop browser by the host environment. (Much like the DOM) -- the javascript language doesn't define the navigator
object so V8 (the underlying engine) doesn't provide it and since node isn't a browser, it doesn't implement the navigator
object either.
Processing is designed to be used solely in the browser -- either you're going to need to provide a shimmed environment for it in node, or use it in the browser (either headless or not)