pm5 / node-openrefine

OpenRefine client in Node.js
Other
16 stars 5 forks source link

Installation and usage #2

Open danpaulsmith opened 8 years ago

danpaulsmith commented 8 years ago

Hi,

I'd like to try this out, but not sure how to.

I have a working version of OpenRefine on a linux box.

I have also installed this package via npm install openrefine

When I try to run a basic script it errors with this:

node openrefine-nodeserver.js

/opt/www/openrefine/openrefine-2.6-rc.2/node_modules/openrefine/lib/openrefine.js:22
class Project {
^^^^^
SyntaxError: Unexpected reserved word
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/opt/www/openrefine/openrefine-2.6-rc.2/node_modules/openrefine/index.js:4:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

Has this been written in ES6? The syntax looks funny for a node script. Then again, I could just be out of touch with what's allowed in NodeJS scripts these days...!

danpaulsmith commented 8 years ago

Looking into this a bit more, I realise this has been written in es6, and I think I need a transpiler such as Babel to convert it to native NodeJS. I'm not having much luck.

Would you mind adding to the README some simple steps in order to get a simple script working, using this for example:

var openrefine = require('openrefine')

// another server; same usage
var server = openrefine.server('http://localhost:3333')

// projects metadata
openrefine
  .projects()
  .then(console.log)