更新到 Grunt 导致 "Use of const in strict mode" 错误

Update to Grunt causes "Use of const in strict mode" error

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

K:\_work\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 在构建期间。

有什么办法可以解决这个问题吗?这里的其他类似问题说我需要一个新版本的 Node,但如果我这样做,我的构建就会在其他地方中断(参见 this question)。

我们也遇到了这个问题。结果我们的构建代理开始使用 grunt@1.0.3 node_modules/grunt(不知道如何或为什么,看起来这个 grunt 更新发生在 16 天前,但它今天才在我们的代理上发生变化)

这似乎依赖于: 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 似乎依赖于 chalk,它似乎依赖于: 转义字符串正则表达式 (https://www.npmjs.com/package/grunt-legacy-log-utils/v/2.0.1)

我们通过指定 grunt@1.0.2 解决了构建问题,它使用:

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 后,构建开始工作。希望对您有所帮助!