【问题标题】:Grunt will simply not install on my Win 8.1 machineGrunt 根本不会安装在我的 Win 8.1 机器上
【发布时间】:2015-01-07 00:08:03
【问题描述】:

我在 root(C:/) 中创建了一个文件夹 g,我尝试通过 npm 安装 Grunt。 我成功了:npm install -g grunt-cli。 我将 package.json 配置为:

{
    "name": "testing",
    "version": "0.0.0",
    "dependencies": {
    "grunt": "~0.4.5" },
    "description": "testing",
    "main": "index.html",
    "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
    "author": "",
    "license": "ISC",
    "devDependencies": {
    "grunt": "^0.4.5"
  }
}

到目前为止一切顺利。 但是:当我尝试安装 Grunt 时:npm install grunt --save-dev and modules(plugins) 然后我遇到了这个错误:npm WARN package.json testing@0.0.0 No repository field...

我在 GitHub 上使用了 Grunt 和 Grunticon 的分支。

那么我就无法安装 Grunt...

有什么好的线索和帮助解决这个问题吗?

【问题讨论】:

  • 警告就是:警告。它们不是错误。要么事情应该正常工作,要么您可能收到不同的错误。我们需要更多信息来提供帮助。当您运行npm install grunt --save-dev 时,您可以使用控制台的输出更新问题吗?
  • npm WARN package.json testing@0.0.0 没有存储库字段。 npm WARN package.json testing@0.0.0 没有 README 数据 grunt@0.4.5 node_modules\grunt
  • ├── dateformat@1.0.2-1.2.3 ├── which@1.0.8 ├── eventemitter2@0.4.14 ├── getobject@0.1.0 ├── rimraf@2.2 .8 ├── colors@0.6.2 ├── async@0.1.22 ├── hooker@0.2.3 ├── grunt-legacy-util@0.2.0 ├── exit@0.1.2 ├── lodash @0.9.2 ├── coffee-script@1.3.3 ├── iconv-lite@0.2.11 ├── underscore.string@2.2.1 ├── nopt@1.0.10 (abbrev@1.0.5) ├ ── minimatch@0.2.14 (sigmund@1.0.0, lru-cache@2.5.0) ├── glob@3.1.21 (inherits@1.0.0, graceful-fs@1.2.3) ├── js- yaml@2.0.5 (esprima@1.0.4, argparse@0.1.16) ├── grunt-legacy-log@0.1.1 (underscore.string@2.3.3, lodash@2 └── findup-sync@0.1 .3 (lodash@2.4.1, glob@3.2.11)
  • 嘿@tomwell,这真的很难阅读,您可以编辑问题并将其添加到那里(然后删除那些 cmets)吗?我会看看我今天是否可以重新创建这个问题,但我不确定现在到底发生了什么。
  • 在我的 Win 8.1 计算机中,我在根目录 (C:) 中创建了一个 g 文件夹。

标签: gruntjs


【解决方案1】:

好的,我想我现在清楚地看到了问题所在。以下是让 Grunt 运行的一些说明,请尝试完全按照这些说明操作,不要创建任何其他文件夹,因为这可能会导致 Grunt 或 Node 出现问题。

  1. 为您的项目创建一个文件夹,它可以在您系统上的任何位置。
  2. 将上面的文件保存为该文件夹中的package.json。
  3. 现在安装全局 Grunt CLI
    ~$ npm install -g grunt-cli
  4. 然后转到您创建的新目录并运行以下命令:
    ~/new-directoty$ npm install
    这将为您的项目在本地安装 Grunt 运行时,因为它在 package.json 中指定
  5. 在新目录下创建一个非常简单的配置文件,命名为Gruntfile.js:

    module.exports = function(grunt) { grunt.initConfig({ /* your config will go in here */ }); /* multi-task definitions go here */ };

  6. 现在尝试运行 Grunt 以测试它是否有效:
    ~/new-directory$ grunt

之后,您就可以开始添加插件了,但这是一个更大的话题。祝你好运。

【讨论】:

  • 您好!谢谢回复。当我使用非常简单的 Gruntfile.js: 4 行遵循您的建议时,我得到了这个
  • 当我在 bash 终端中运行 Grunt -> 警告:找不到任务“默认”。使用 --force 继续。然后我做了一个 grunt --force 然后它带有:完成,但有警告。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-05-27
  • 2017-04-26
  • 2013-05-12
  • 2014-01-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多