0

It would be very helpful for me to test my parse.com javascript code in an interpreter environment. So I can query an object and see the response immediately.

Node.js comes with an interpreter, but I need to figure out how to import the parse object. This seems to be done through the parse.js file (http://www.parsecdn.com/js/parse-1.2.19.min.js). In the parse tutorials it is included in <script> tags in the html like so

<script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.2.19.min.js"></script>

But for this I need to figure out how to do the import using javascript. Does anyone know how to import an external file? I tried require("http://www.parsecdn.com/js/parse-1.2.19.min.js") but got an error.

Update:

I was able to import the Parse code by downloading the parse file and using require locally with
var Parse = require("./parse-1.2.19.min.js");

Localstorage and xmlhttprequest have to be installed beforehand for this to work. However when I do Parse.initialize(-removed keys-) I get

TypeError: Object function (e){return e instanceof w?e:this instanceof w?(this._wrapped=e,void 0):new w(e)} has no method 'initialize'

1
  • Using var Parse = require("./parse-1.2.19.min.js").Parse; and installing localstorage and xmlhttprequest also worked! Directly installing parse using npm as suggested in Paul's answer is more elegant, however. Commented Aug 14, 2014 at 4:52

1 Answer 1

1

So you won't use the CDN file, since that's written for the browser and the environment is different.

From the parse.com blog, you can get the SDK for nodejs through npm and then require it like you normally would in node.

npm install parse

var parse = require('parse').Parse;

Full article here: http://blog.parse.com/2012/10/11/the-javascript-sdk-in-node-js/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.