【问题标题】:Multiple issues running grunt.cmd on windows在 Windows 上运行 grunt.cmd 的多个问题
【发布时间】:2012-10-08 14:42:39
【问题描述】:

我不得不修改 grunt.cmd 因为我的系统路径非常错误:

原来:

%~dp0\Application Data\npm\node_modules\grunt

哪个会打印:

\\dacwnas\Profiles\<user>\Application Data\npm\Application Data\npm\node_modules\grunt

运行 grunt.cmd 会抛出找不到模块错误。将其更改为 %~dp0\node_modules\grunt" 可消除该错误。

但是,在 Windows 中运行 grunt.cmd --version 不会输出任何结果。它只是暂停片刻,然后返回到空白命令行。

我运行的是 Windows 7 64 位,命令行以管理员身份运行

【问题讨论】:

  • 你是如何安装 grunt 的? npm install -g grunt? grunt.cmd 文件由 npm 自动生成,不应编辑。更正系统路径后,尝试使用 npm 重新安装 grunt。
  • @KyleRobinsonYoung:如果 npm 第一次把错误的路径放在那里,我不明白为什么如果他重新安装它会做得更好。在我看来,当用户有一个重定向的应用程序数据文件夹时,Grunt 中出现了一个错误。
  • npm 自动生成grunt.cmd 文件时,Grunt 怎么会出bug?他指出的问题,可能是他所有全局安装的节点模块的问题,而不仅仅是 Grunt。如果他更正系统路径并重新安装,npm 应该生成正确的 grunt.cmd 文件。
  • 我想远程配置文件是导致问题的原因。我可以手动安装 npm 和 node。我还没有尝试过任何其他软件包,但我认为我会遇到类似的问题。
  • @KyleRobinsonYoung:npm 在创建 grunt.cmd 时如何使用 %PATH%?我没有看到联系。在我看来,它好像正在使用 %APPDATA% 或等效项,并且在它不以驱动器号开头时无法应对。 (但是,我可能应该说 npm 中的错误而不是 Grunt 中的错误。)

标签: windows node.js gruntjs


【解决方案1】:

首先,您应该全局安装grunt-cli 包:

npm install -g grunt-cli

接下来,确保您在项目文件夹中安装了grunt

您可以这样做:

  • 确保grunt 是您的package.json 的一部分并运行:npm install
  • 转到您的项目文件夹,只需 npm install grunt

在此之后,运行 Grunt 应该不会有任何问题。

【讨论】:

    【解决方案2】:

    你安装了 grunt-cli 吗?

    我的 grunt.cmd 内容如下所示:

    :: Created by npm, please don't edit manually.
    @IF EXIST "%~dp0\node.exe" (
      "%~dp0\node.exe"  "%~dp0\node_modules\grunt-cli\bin\grunt" %*
    ) ELSE (
       node  "%~dp0\node_modules\grunt-cli\bin\grunt" %*
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-26
      • 1970-01-01
      • 1970-01-01
      • 2022-12-01
      • 1970-01-01
      相关资源
      最近更新 更多