I'm currently using a package for running cross browser javascript tests called easy-sauce
. In short, my package.json
file calls that for the test
command:
{
"scripts": {
"test": "easy-sauce"
}
}
When I'm using a Node 6 environment, and run npm test
, all is well. However, the project I'm using it with still needs Node 5.6.0. When I run npm test
in this environment, I see the following error:
/data/projects/easytest/node_modules/easy-sauce/lib/cli.js:114
function formatResult(result = {}) {
^
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/data/projects/easytest/node_modules/easy-sauce/bin/easy-sauce:6:13)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
Is there a way to get this working within the Node 5.6.0 environment?
This error isn't related to the easy-sauce package, it has to do with your version of node.
According to node.green, default parameters were added in version 6.2.2
Unfortunately you wont be able to run the code in node 5. Default parameters are in node 6.2, hence that error.
Option 1 Upgrade your version of node/npm. This is not always possible, depending on deployment environment.
Option 2 You need to use a transpiler (eg Babel) to convert the ES6 code to ES5 and reference the built script. This solution is the one you always have the power to do.
Option 3 Fork/update easy-sauce
to include a transpiler to build an ES5 version (in the dist
folder is a common destination). The package.json of the package can be directed to this location.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.