【问题标题】:Configuring Grunt Task in the Release Pipeline在发布管道中配置 Grunt 任务
【发布时间】:2018-05-13 08:13:12
【问题描述】:

我已将 Grunt 任务添加到我的发布管道中。当 Grunt 任务运行时,我收到以下错误:

Grunt-cli is not installed globally (or is not in the path of the user the agent is running as) and it is not in the local working folder:

C:\agent\_work\r9\a\node_modules\grunt-cli\bin\grunt

知道如何纠正这个错误吗?

【问题讨论】:

  • 你是否在 Grunt 任务之前添加了 npm install 任务?你能把整个构建日志放在这里吗?

标签: gruntjs azure-pipelines-release-pipeline


【解决方案1】:

要确定您的系统上是否全局安装了grunt-cli,请通过您的 CLI 运行以下命令:

npm list -g grunt-cli

如果它报告(empty),则通过运行全局安装grunt-cli

npm install -g grunt-cli

【讨论】:

  • 在构建代理上将其安装为服务帐户后仍然出现错误。
  • 显示为空。所以我运行 npm install -g grunt-cli。显示更新的 1 个包。然后我运行 npm list -g grunt-cli 它再次显示为空。
【解决方案2】:

我们在(自托管)代理上的构建管道遇到了同样的问题...

我尝试在本地安装 grunt-cli,但也没有成功。

在脚本任务中运行命令npm list -g 后,在yaml 中:- script: npm list -g,我发现代理有另一个全局文件夹,应该如下所示(取决于哪个用户运行azure pipelines agent 服务,对于我是(local-system):

C:\Windows\system32\config\systemprofile\AppData\Roaming\npm

所以,我将grunt-task 配置为在该位置的node_modules 中搜索grunt-cli。在yaml 管道计划中,它看起来像这样:

# Need to run at the first build, then set enabled to false
- task: Npm@1
  enabled: false
  inputs:
    command: 'custom'
    customCommand: 'install -g grunt-cli'

- task: Grunt@0
  displayName: Run Grunt tasks
  inputs:
    gruntFile: Gruntfile.js
    gruntCli: 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt'

我必须在管道中运行 npm i -g grunt-cli 才能为代理全局安装 grunt-cli。

跳一下会很有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多