简体   繁体   English

Bower在运行grunt发球后抛出jquery“未注入”警告

[英]Bower throws jquery “not injected” warning after running grunt serve

I've recently had to clone an project and rebuild bower packages. 我最近不得不克隆一个项目并重建bower包。 jQuery has updated I believe, and is now throwning an warning: 我相信jQuery已更新,现在正在发出警告:

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

I've done this. 我做到了这一点。 And everythign works properly. 并且每个标志都正常工作。 However, everytime I grunt serve the warning still gets thrown? 但是,每次我grunt serve发出警告仍然会被抛出?

jquery was not injected in your file.

How do I remove this error? 如何删除此错误? and will this error out a grunt build? 并且这会导致一个笨拙的构建错误吗? I'm sure the warning is harmless but it's really upsetting to keep seeing it. 我确信这个警告是无害的,但是看到它真的很难过。

main .bower.json 主要.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 .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"
}

You can workaround this problem changing the bower.json of your project and override some package with problem 您可以解决此问题,更改项目的bower.json并覆盖一些有问题的包

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

You can sse more about that in https://github.com/bower/bower/issues/585 您可以在https://github.com/bower/bower/issues/585中了解更多信息

But, looks like that current version of the JQuery is playing into the Bower rules. 但是,看起来当前版本的JQuery正在玩Bower规则。

As explained on the related Github issues available here: https://github.com/stephenplusplus/grunt-bower-install/issues/55 正如在此处提供的相关Github问题所述: https//github.com/stephenplusplus/grunt-bower-install/issues/55

This isn't an error with grunt-bower-install - this is, sadly, jQuery not playing by Bower's rules. 这不是grunt-bower-install的错误 - 遗憾的是,jQuery没有遵循Bower的规则。 It's not possible for this tool to work with a Bower package that doesn't specify main property. 此工具无法使用未指定main属性的Bower包。 Like any other package that doesn't, the solution is to manually include the reference to the file inside of your HTML file, like the good ol' days 像任何其他没有的软件包一样,解决方案是手动包含对HTML文件内部文件的引用,就像好日子一样

I'm sorry man, I had the same problem just now :( 我很抱歉,我刚才有同样的问题:(

In general, if you get this error it is because the author of whatever bower component you are using either hasn't included a bower.json file in the component or hasn't define a "main" property in the bower.json folder. 通常,如果您收到此错误,那是因为您使用的任何bower组件的作者未在组件中包含bower.json文件或未在bower.json文件夹中定义“main”属性。 If the component is being actively maintained, you should open a github issue asking for a proper bower.json file in the component. 如果正在主动维护组件,则应该打开github问题,要求在组件中使用正确的bower.json文件。 Here is an real world example... 这是一个现实世界的例子......

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM