Mocha: Mocha fails on travis because of strict mode

Created on 11 Feb 2018  路  7Comments  路  Source: mochajs/mocha

Hi,

I use mocha in most of my libs and got an error recently:

> mocha tests/*.js
/home/travis/build/infusion/BitSet.js/node_modules/mocha/bin/mocha:10
const spawn = require('child_process').spawn;
^^^^^
SyntaxError: Use of const in strict mode.
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
npm ERR! Test failed.  See above for more details.
The command "npm test" exited with 1.
Done. Your build exited with 1.

Is this a bug or do I have to do something to fix that?

Thanks, Robert

Most helpful comment

language: "node_js"
node_js:
    - "node"

The above should work. However, without specification of the language parameter on .travis.yml file as above, Travis ends up trying Ruby as the default language and hits an error. [just as an addition]

All 7 comments

you are probably using an older version of Node.js (Travis is). You have to update your Node.js version.

Yea, locally everything works just fine. Then waiting...thanks!

@infusion You can tell Travis which version of Node to use in your .travis.yml file:

node_js:
  - "node"

In my example, it will use the latest stable release. More information on versions here.

Sarah, thanks for the explanation, I had it like this in all projects but the failing project was missing the "node" entry. It's all fine now :)

language: "node_js"
node_js:
    - "node"

The above should work. However, without specification of the language parameter on .travis.yml file as above, Travis ends up trying Ruby as the default language and hits an error. [just as an addition]

Where can I find travis.yml file. I am using node v10.38. It doesn't use .nvmrc, am I missing out on anything?

you create a .travis.yml file, to hold your configurations when running Travis.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jbnicolai picture jbnicolai  路  37Comments

Almad picture Almad  路  41Comments

domenic picture domenic  路  43Comments

KylePDavis picture KylePDavis  路  71Comments

teckays picture teckays  路  84Comments