I am looking to perform canvas tests exclusively in node.js.
Here is my package.json
{
"name": "test",
"description": "Test",
"version": "0.1.0",
"author": "anthony@work",
"dependencies": {
"canvas": "^1.6.7",
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-0": "^6.24.1",
"jsdom": "^11.3.0"
}
}
This is the content of my .babelrc file
{
"presets": ["env", "stage-0"]
}
Below is the code from my test javascript file (a.js
)
const { jsdom } = require('jsdom');
// main
jsdom();
console.log('done')
However, when I try to run the script using:
npx babel a.js | nodejs -- -
I encounter this error:
/work/node_modules/jsdom/lib/api.js:10
const { URL } = require("whatwg-url");
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at [stdin]:3:16
at Object.exports.runInThisContext (vm.js:54:17)
at Object.<anonymous> ([stdin]-wrapper:6:22)
What could be causing this error and how can I resolve it?
Version information:
Node.js: v4.2.6 OS: Ubuntu 16.04