Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Karma throws error: Can not load "ng-html2js", it is not registered

I'm getting an error when I run karma start:

$ karma start
INFO [karma]: Karma v0.10.2 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
WARN [preprocess]: Can not load "ng-html2js", it is not registered!
  Perhaps you are missing some plugin?

...

But in my package file I have "karma-ng-html2js-preprocessor": "*", and the folder with code for this preprocessor exists in node_modules.

Any ideas on how to solve the problem?

like image 783
Ph0en1x Avatar asked Sep 28 '13 16:09

Ph0en1x


3 Answers

In my cases, the problem was connected to lack of karma-ng-html2js-preprocessor inside karma config plugins sections. In tutorials I saw that you don't need to add 'ng-html2js' inside plugins, but for me it doesn't work without it.

like image 158
Ph0en1x Avatar answered Nov 20 '22 14:11

Ph0en1x


If you are starting and running a global install of Karma, one that's installed with -g flag, and is run without specifying a path, i.e. karma start path/to/config.js, then make sure the plugins are also globally installed, i.e. npm install -g karma-ng-html2js-preprocessor.

If you're running a local install of Karma, i.e. path/to/karma start path/to/config.js then make sure plugin is also installed locally to that application.

like image 23
M.K. Safi Avatar answered Nov 20 '22 13:11

M.K. Safi


Check out Loading Plugins in the docs.

If you omit the plugins property, it'll try to load all the plugins that are:

  1. Prefixed with karma-.
  2. A sibling to the karma npm module.

So if your file structure is:

- node_modules
  - karma
  - karma-chrome-launcher
  - karma-firefox-launcher

...since karma-chrome-launcher and karma-firefox-launcher are siblings to the karma module that is in use, and since they both start with karma- they'll be loaded automatically.


But be careful - if you do have the plugins property defined, it'll only load the things that are defined. Ie. if you have plugins: ['karma-chrome-launcher'], it won't load karma-firefox-launcher.


Some questions to ask yourself:

  1. Are you using a local version of karma or a global version?
  2. Is everything up to date? If not try npm update or npm uninstall -> npm install.
  3. Do you have global versions of karma-x that are overriding the local ones?
like image 10
Adam Zerner Avatar answered Nov 20 '22 14:11

Adam Zerner