简体   繁体   English

更新为Grunt会导致“在严格模式下使用const”错误

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

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: 我在构建服务器上做了一些事情,导致Grunt得到更新(哎呀),现在使用新版本的grunt-legacy-log-utils卡住了,它会产生以下结果:

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. 我已经尝试过在全球范围内手动拉入旧版本,以及专门向项目的package.json文件中添加grunt-legacy-log-utils ,但是在构建过程中运行npm install时,它仍会拉低最新版本。

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 ). 此处的其他类似问题说我需要一个新版本的Node,但是如果这样做,我的构建将在其他地方中断(请参阅此问题 )。

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@1.0.3 node_modules / grunt(不确定如何或为什么,这似乎是16天前进行的grunt更新,但今天对我们的代理才进行了更改)

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@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 ) 使用grunt-legacy-log-utils@2.0.1似乎依赖粉笔,似乎依赖于: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@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-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. 将构建重新设置为使用grunt <1.0.3后,构建开始工作。 Hope it helps! 希望能帮助到你!

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

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