【问题标题】:Bower throws jquery "not injected" warning after running grunt serveBower 在运行 grunt serve 后抛出 jquery“未注入”警告
【发布时间】:2014-02-19 20:44:22
【问题描述】:

我最近不得不克隆一个项目并重建 bower 包。我相信 jQuery 已经更新,现在发出警告:

警告:
Please go take a look in "app/bower_components/jquery" for the file you need, then manually include it in your file.

我已经做到了。一切正常。但是,每次我grunt serve 时仍然会抛出警告?

jquery was not injected in your file.

如何消除此错误?这个错误会产生咕噜声吗?我确信这个警告是无害的,但看到它真的很令人沮丧。

ma​​in .bower.json

{
  "name": "jordan",
  "version": "0.0.0",
  "dependencies": {
    "angular": "1.2.6",
    "json3": "~3.2.6",
    "es5-shim": "~2.1.0",
    "angular-resource": "1.2.6",
    "angular-cookies": "1.2.6",
    "angular-sanitize": "1.2.6",
    "angular-route": "1.2.6",
    "jquery-ui": "~1.10.3"
  },
  "devDependencies": {
    "angular-mocks": "1.2.6",
    "angular-scenario": "1.2.6"
  }
}

.bower.json for jquery

{
  "name": "jquery",
  "version": "2.1.0",
  "ignore": [
    "**/.*",
    "build",
    "speed",
    "test",
    "*.md",
    "AUTHORS.txt",
    "Gruntfile.js",
    "package.json",
    "bower.json"
  ],
  "dependencies": {
    "sizzle": "1.10.16"
  },
  "devDependencies": {
    "requirejs": "~2.1.8",
    "qunit": "~1.12.0",
    "sinon": "~1.7.3"
  },
  "keywords": [
    "jquery",
    "javascript",
    "library"
  ],
  "homepage": "https://github.com/jquery/jquery",
  "_release": "2.1.0",
  "_resolution": {
    "type": "version",
    "tag": "2.1.0",
    "commit": "cac43f3ef791b7e68c1917a734fb92e04450c111"
  },
  "_source": "git://github.com/jquery/jquery.git",
  "_target": ">=1.6",
  "_originalSource": "jquery"
}

【问题讨论】:

    标签: javascript jquery json yeoman bower


    【解决方案1】:

    您可以通过更改项目的 bower.json 来解决此问题并覆盖一些有问题的包

    "overrides": {
      "jquery": {
        "main": "./dist/jquery.js"
      }
    }
    

    您可以在https://github.com/bower/bower/issues/585 中了解更多信息

    但是,当前版本的 JQuery 似乎符合 Bower 规则。

    【讨论】:

    • 这是一个有用的答案!
    【解决方案2】:

    正如在此处可用的相关 Github 问题中所解释的: https://github.com/stephenplusplus/grunt-bower-install/issues/55

    这不是 grunt-bower-install 的错误——遗憾的是,jQuery 没有遵守 Bower 的规则。此工具无法与未指定 main 属性的 Bower 包一起使用。与其他任何不这样做的包一样,解决方案是手动在 HTML 文件中包含对文件的引用,就像美好的过去一样

    对不起,我刚才遇到了同样的问题:(

    【讨论】:

    • 那么没有已知的方法可以“抑制”这些恼人的警告吗?
    【解决方案3】:

    一般来说,如果您收到此错误,那是因为您使用的任何 bower 组件的作者都没有在组件中包含 bower.json 文件,或者没有在 bower 中定义“main”属性。 .json 文件夹。如果组件正在积极维护,您应该打开一个 github 问题,要求在组件中提供适当的 bower.json 文件。这是一个真实世界的例子......

    https://github.com/CreateJS/SoundJS/issues/76

    【讨论】:

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