简体   繁体   中英

Syntax error while executing mocha test runner

I have written a small Node.js app containing the following code and it's corresponding API test. However when I invoke the test, the following error is displayed about mocha:

C:\Users\HP\Downloads\NodeJSPortable\Data\node_modules\mocha\bin\mocha:13
const {deprecate} = require('../lib/utils');
  ^

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 Function.Module.runMain (module.js:447:10)
    at startup (node.js:141:18)
    at node.js:933:3

C:\Users\HP\Downloads\NodeJSPortable\Data>

截屏

Any idea what could be the fix?

You're just using an old version of javascript. Upgrade to a newer version of nodejs, or change it to something backward-compatible. const deprecate = require('../lib/utils').deprecate; should do it.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM