Update to Grunt causes “Use of const in strict mode” error

别等时光非礼了梦想. 提交于 2019-12-11 00:55:16

问题


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.

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.

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).


回答1:


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)

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)

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)

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)

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



来源:https://stackoverflow.com/questions/50688988/update-to-grunt-causes-use-of-const-in-strict-mode-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!