I’m not having much luck with SparkJS and have probably missed something really simple. I’m following the instructions at http://docs.spark.io/javascript/. I go to http://nodejs.org/ and click the big green install button, click “Run” and the installer installs NodeJS. Then I open a command line and type “npm install spark”. It displays this:
spark@0.2.1 node_modules\spark
├── when@3.4.6
└── request@2.44.0 (caseless@0.6.0, aws-sign2@0.5.0, forever-agent@0.5.2, tunnel-agent@0.4.0, json-stringify-safe@5.0.0, oauth-sign@0.4.0, stringstream@0.0.4, qs@1.2.2, mime-types@1.0.2, node-uuid@1.4.1, tough-cookie@0.12.1, hawk@1.1.1, http-signature@0.10.0, bl@0.9.3, form-data@0.1.4)
I assume this is correct.
Then I create this HTML file:
<!DOCTYPE html>
<!-- Source file: index.html -->
<html>
<body>
<p>Testing SparkJS</p>
<script type="text/javascript" src="//cdn.jsdelivr.net/sparkjs/0.2.0/spark.min.js">
</script>
<script src="js\index.js"></script>
</body>
</html>
and this JavaScript file:
/*
* Source file: index.js
* Javascript code included in index.html.
*/
var spark = require('spark');
I then open index.html in a browser (in this case I used Chrome) and I get this message in the browser console window:
Clearly it has no idea about the require function. Now I think the require function is part of NodeJS but there is nothing in the HTML that references NodeJS and I cannot see anything that does this in the example documents. So, what is it I have to do to gain access to the require function? Any help appreciated.
I am doing all this on a Windows 7 computer.