简体   繁体   English

SyntaxError:在github和codeship中以严格模式使用const

[英]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. 当我在源代码Github / Codeship中运行grunt test时,发现以下错误。

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. 但是该错误未在我的源代码中找到,而是通过查看codeship给出的以下错误消息在github / 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.

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. 您的项目当前使用的节点版本为0.12.6 ,这已经过时了。 The current LTS version of Node is 6.11.3 and the current version is 8.6.0 . Node的当前LTS版本是6.11.3 ,当前版本是8.6.0

The specific issue is SyntaxError: Use of const in strict mode. 具体的问题是SyntaxError: Use of const in strict mode. which means the libraries you are using are currently utilizing ES2015 syntax or higher. 这意味着您正在使用的库当前正在使用ES2015语法或更高版本。 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). 造成此问题的根本原因是在Boom模块中,该模块在第5行使用const (并且很可能还有其他当前语法)。

The solution for your issue here is to update the node version being utilized inside Codeship. 您这里遇到的问题的解决方案是更新Codeship中正在使用的节点版本。

nvm install 6.11.3
nvm use 6.11.3

simple way. 简单的方法。 just upgrade your node by below code: 只需通过以下代码升级您的节点:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

enjoy! 请享用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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