更新为Grunt会导致“在严格模式下使用const".错误 [英] Update to Grunt causes "Use of const in strict mode" error

查看:94
本文介绍了更新为Grunt会导致“在严格模式下使用const".错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在构建服务器上做了一些事情,导致Grunt得到更新(哎呀),现在它被使用新版本的grunt-legacy-log-utils卡住了,产生了以下内容:

I did some things on our build server, which resulted in Grunt getting updated (oops), and it is now stuck using a new version of grunt-legacy-log-utils, which produces the following:

K:\_work\4\s\Web\node_modules\grunt\node_modules\grunt-legacy-log\node_modules\grunt-legacy-log-utils\node_modules\chalk\index.js:2
const escapeStringRegexp = require('escape-string-regexp');
^^^^^
SyntaxError: Use of const in strict mode.

我尝试在全局范围内手动拉入旧版本,以及将grunt-legacy-log-utils专门添加到项目的package.json文件中,但是在构建过程中运行npm install时,它仍会拉低最新版本.

I have tried manually pulling in an older version globally, as well as specifically adding grunt-legacy-log-utils to the project's package.json file, but it still pulls down the latest version when running npm install during the build.

有什么办法可以解决这个问题?此处的其他类似问题说我需要新版本的Node,但如果这样做,我的构建将在其他地方中断(请参阅

Is there any way to get around this? Other similar questions on here say I need a new version of Node, but if I do that my build breaks elsewhere (see this question).

推荐答案

我们也遇到了此问题.事实证明,我们的构建代理开始使用grunt@1.0.3 node_modules/grunt(不确定如何或为什么,这似乎是16天前进行的grunt更新,但今天在我们的代理上才发生变化)

We encountered this issue as well. Turns out our build agents started using grunt@1.0.3 node_modules/grunt (not sure how or why, it looks like this update to grunt happened 16 days ago, but it just changed on our agents today)

似乎依赖于: grunt-legacy-log@2.0.0(hooker@0.2.3,colors@1.1.2,grunt-legacy-log-utils@2.0.1,lodash@4.17.10)

Which appears to rely on: grunt-legacy-log@2.0.0 (hooker@0.2.3, colors@1.1.2, grunt-legacy-log-utils@2.0.1, lodash@4.17.10)

使用grunt-legacy-log-utils@2.0.1似乎依赖粉笔,而粉笔似乎依赖于: escape-string-regexp( https://www.npmjs .com/package/grunt-legacy-log-utils/v/2.0.1 )

With grunt-legacy-log-utils@2.0.1 which appears to rely on chalk, which appears to rely on: escape-string-regexp (https://www.npmjs.com/package/grunt-legacy-log-utils/v/2.0.1)

我们通过指定使用以下内容的grunt@1.0.2解决了构建问题:

We resolved the build issue by specifying grunt@1.0.2 which uses:

grunt-legacy-log@1.0.2(hooker@0.2.3,colors@1.1.2,grunt-legacy-log-utils@1.0.0,lodash@4.17.10)

grunt-legacy-log@1.0.2 (hooker@0.2.3, colors@1.1.2, grunt-legacy-log-utils@1.0.0, lodash@4.17.10)

将构建重新设置为使用grunt<.1.0.3之后,构建开始工作.希望对您有帮助!

After setting the build back to using grunt <1.0.3 the build started working. Hope it helps!

这篇关于更新为Grunt会导致“在严格模式下使用const".错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆