node.jsgithubcodeshipsparkpost

SyntaxError: Use of const in strict mode inside github and codeship


I've found following error when I run grunt test inside my source code Github/Codeship.

In setup command inside codeship, following code are configured like that.

nvm install 0.12.6
nvm use 0.12.6
npm install grunt-cli bower -g
npm install
bower install -p
npm run update-webdriver

and test commands inside codeship;

grunt test

But that error not found inside my source code, and actually found inside github/codeship by viewing following error message given by codeship. Because those folder structure is not defined as we configure in our server. Please help me how to solve it. Thanks.

Using 2 x hasMany to represent N:M relations has been deprecated. Please use belongsToMany instead
>> Mocha exploded!
>> /home/rof/src/github.com/MyProjects/node_modules/sparkpost/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js:5
>> const Hoek = require('hoek');
>> ^^^^^
>> 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 Module.require (module.js:365:17)
>>     at require (module.js:384:17)
>>     at Object.<anonymous> (/home/rof/src/github.com/MyProjects/node_modules/sparkpost/node_modules/request/node_modules/hawk/lib/index.js:5:33)
>>     at Module._compile (module.js:460:26)
>>     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 Module.require (module.js:365:17)
>>     at require (module.js:384:17)
>>     at Object.<anonymous> (/home/rof/src/github.com/MyProjects/node_modules/sparkpost/node_modules/request/request.js:9:12)
>>     at Module._compile (module.js:460:26)
Warning: Task "mochaTest:src" failed. Use --force to continue.

Solution

  • Because those folder structure is not defined as we configure in our server.

    This issue has nothing to do with folder structures.

    Your project is currently using Node version 0.12.6 which is extremely out of date. The current LTS version of Node is 6.11.3 and the current version is 8.6.0.

    The specific issue is SyntaxError: Use of const in strict mode. which means the libraries you are using are currently utilizing ES2015 syntax or higher. The root cause of the issue is in the Boom module, which uses const at line 5 (and most likely other current syntax as well).

    The solution for your issue here is to update the node version being utilized inside Codeship.

    nvm install 6.11.3
    nvm use 6.11.3