Remove warning for package "was not entered in your file" when using Grunt?

I have "angular-i18n" installed as bauer dependency.

When I run grunt serve

or grunt build

, I get a warning:

angular-i18n was not injected into your file. Please take a look at "/ $ APP_ROOT / bower_components / angular-i18n" for the file you need, then manually include it in your file.

How do I delete this message?

Does inserting this file into my index.html help this warning?

+3


source to share


2 answers


Background

It looks like your Grunt tasks are using wiredep

to look at Bower dependencies and inject tags to load related files ( link

for CSS, script

for JS, etc.) into your HTML.

wiredep

does this by looking at the file bower.json

in your project to figure out what you need, and then looking in the file of bower.json

each dependency to figure out what they need, and so on. After designing the dependency tree, it wiredep

uses a property in files to determine which files from each required package should be associated with your HTML. main

bower.json

If a package does not have an appropriate balancing configuration (missing bower.json

or missing / wrong property main

), it wiredep

alerts you to this problem, so you know it cannot automatically add what you need. In other words, it tells you that not all assets have been added to your inline HTML and that you need to manually intervene to add the missing ones.

Common decision

Generally, there is nothing you can do in your own code to fix this. Manually linking the file in HTML (outside the marked areas wiredep

to avoid overwriting it) will ensure that your project works. wiredep

however, will always alert you when it works because the package itself still has a problem. You will need to open the issue to the owner of the issue package to ask them to fix their packaging meta information.

The project is having problems with



I searched bower for the packageangular-i18n

and found the project is hosted at https://github.com/angular/bower-angular-i18n . If you look , you can see the property is missing . This is why the warning is issued. angular-i18n

bower.json

main

As it turns out, it seems advisable that this project does not offer a property main

. The documentation forangular-i18n

shows what you should bower install

and then manually link to the file corresponding to your desired language. It would be impractical for this package to render a file main

as it provides many files, none of which should be dictated by the package as needed - it's the developer's choice.

Possible solution for this case

If the warning really bothers you, or you don't like the need to manually connect to the file, you can split that package into your own GitHub account and change the file bower.json

to dot main

for the file you want to download. Then you will remove angular-i18n

as a dependency for your project and add the fork replica as a dependency instead.

Caveats:

  • This can lead to unsatisfactory problems if you are not familiar with Git repos / forks support.
  • This will only work if it angular-i18n

    appears as an explicit dependency of your own project and is not loaded as a dependency for another project. If another project downloads this package, you will need to run projects all the way down the tree so you can override the configuration of each one.

In general, in this case, your best bet is to manually link the file to the file you want and ignore the warning.

+11


source


I am getting this error using angular-i18n in a yoman project. This error message specifies wiredep grunt. There are 2 solutions:

1. Exclude angular-i18n and include the file manually in index.html

Gruntfile.js

wiredep: {
  app: {
    src: ['<%= yeoman.app %>/index.html'],
    ignorePath:  /\.\.\//,
    exclude: [
      'bower_components/angular-i18n'
    ]
  }
}

      

index.html

<script src="bower_components/angular-i18n/angular-locale_de-de.js"></script>

      



or

2. Override / Set the main attribute bower_components / angular-i18n / bower.json

Gruntfile.js

wiredep: {
  app: {
    src: ['<%= yeoman.app %>/index.html'],
    ignorePath:  /\.\.\//,
    overrides: {
      'angular-i18n': {
        'main': 'angular-locale_de-de.js'
      }
    }
  }
}

      

I decided to go with a second parameter overriding the main attribute. So in index.html the angular-i18n library is still auto-injected by the grunt job.

0


source







All Articles