更新到Grunt会导致"在严格模式下使用const"错误

Dav*_*son 2 node.js gruntjs

我在构建服务器上做了一些事情,这导致Grunt得到更新(oops),现在它使用新版本的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.
Run Code Online (Sandbox Code Playgroud)

我试图在全局范围内手动拉入旧版本,以及专门添加grunt-legacy-log-utils到项目的package.json文件,但它仍然npm install在构建期间运行时拉下最新版本.

有没有办法解决这个问题?这里的其他类似问题说我需要一个新版本的Node,但如果我这样做,我的构建会破坏其他地方(请参阅此问题).

小智 5

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

这似乎依赖于: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)

我们通过指定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之后,构建开始工作.希望能帮助到你!

  • 哈,正是这样做的(从“~1.0.1”改为“1.0.2”),一切都很好。多谢。 (2认同)