Jhipster-generator error on production profile - angularjs

I'm Trying to run my app in production profile, i'm using jhipster-generator for spring-boot app and angular. The app only run the footer and the background but the rest of the aplication nope, The error
Uncaught Error: [$injector:modulerr] Failed to instantiate module myAppdue to:
Error: [$injector:nomod] Module 'myApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.5.8/$injector/nomod?p0=myApp
at http://localhost:8080/app/vendor-7004bf12ca.js:8:17716
at http://localhost:8080/app/vendor-7004bf12ca.js:8:27870
at n (http://localhost:8080/app/vendor-7004bf12ca.js:8:27343)
at http://localhost:8080/app/vendor-7004bf12ca.js:8:27655
at http://localhost:8080/app/vendor-7004bf12ca.js:9:4997
at r (http://localhost:8080/app/vendor-7004bf12ca.js:8:18164)
at f (http://localhost:8080/app/vendor-7004bf12ca.js:9:4845)
at rt (http://localhost:8080/app/vendor-7004bf12ca.js:9:6774)
at a (http://localhost:8080/app/vendor-7004bf12ca.js:8:25413)
at ie (http://localhost:8080/app/vendor-7004bf12ca.js:8:25723)
http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=myApp&p1=Error%3A%20%5B%24injector%3Anomod%5D%20Module%20'myApp'%20is%20not%20available!%20You%20either%20misspelled%20the%20module%20name%20or%20forgot%20to%20load%20it.%20If%20registering%20a%20module%20ensure%20that%20you%20specify%20the%20dependencies%20as%20the%20second%20argument.%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.5.8%2F%24injector%2Fnomod%3Fp0%3DdigitalBlogApp%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A8%3A17716%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A8%3A27870%0A%20%20%20%20at%20n%20(http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A8%3A27343)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A8%3A27655%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A9%3A4997%0A%20%20%20%20at%20r%20(http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A8%3A18164)%0A%20%20%20%20at%20f%20(http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A9%3A4845)%0A%20%20%20%20at%20rt%20(http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A9%3A6774)%0A%20%20%20%20at%20a%20(http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A8%3A25413)%0A%20%20%20%20at%20ie%20(http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A8%3A25723)
at http://localhost:8080/app/vendor-7004bf12ca.js:8:17716
at http://localhost:8080/app/vendor-7004bf12ca.js:8:27870
at n (http://localhost:8080/app/vendor-7004bf12ca.js:8:27343)
at http://localhost:8080/app/vendor-7004bf12ca.js:8:27655
at http://localhost:8080/app/vendor-7004bf12ca.js:9:4997
at r (http://localhost:8080/app/vendor-7004bf12ca.js:8:18164)
at f (http://localhost:8080/app/vendor-7004bf12ca.js:9:4845)
at rt (http://localhost:8080/app/vendor-7004bf12ca.js:9:6774)
at a (http://localhost:8080/app/vendor-7004bf12ca.js:8:25413)
at ie (http://localhost:8080/app/vendor-7004bf12ca.js:8:25723)
http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=myApp&p1=Error%3A%20%5B%24injector%3Anomod%5D%20Module%20'myApp'%20is%20not%20available!%20You%20either%20misspelled%20the%20module%20name%20or%20forgot%20to%20load%20it.%20If%20registering%20a%20module%20ensure%20that%20you%20specify%20the%20dependencies%20as%20the%20second%20argument.%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.5.8%2F%24injector%2Fnomod%3Fp0%3DdigitalBlogApp%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A8%3A17716%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A8%3A27870%0A%20%20%20%20at%20n%20(http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A8%3A27343)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A8%3A27655%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A9%3A4997%0A%20%20%20%20at%20r%20(http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A8%3A18164)%0A%20%20%20%20at%20f%20(http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A9%3A4845)%0A%20%20%20%20at%20rt%20(http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A9%3A6774)%0A%20%20%20%20at%20a%20(http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A8%3A25413)%0A%20%20%20%20at%20ie%20(http%3A%2F%2Flocalhost%3A8080%2Fapp%2Fvendor-7004bf12ca.js%3A8%3A25723)
at http://localhost:8080/app/vendor-7004bf12ca.js:8:17716
at http://localhost:8080/app/vendor-7004bf12ca.js:9:5273
at r (http://localhost:8080/app/vendor-7004bf12ca.js:8:18164)
at f (http://localhost:8080/app/vendor-7004bf12ca.js:9:4845)
at rt (http://localhost:8080/app/vendor-7004bf12ca.js:9:6774)
at a (http://localhost:8080/app/vendor-7004bf12ca.js:8:25413)
at ie (http://localhost:8080/app/vendor-7004bf12ca.js:8:25723)
at re (http://localhost:8080/app/vendor-7004bf12ca.js:8:24962)
at HTMLDocument.<anonymous> (http://localhost:8080/app/vendor-7004bf12ca.js:13:25627)
at p (http://localhost:8080/app/vendor-7004bf12ca.js:2:8692)
what can it be ?

It is probably due to something you changed in index.html because JHipster uses gulp to inject scripts and css into it when building for production. Compare your current version with the one you archived in git at project generation time.

Related

Angular js not responding - help needed

This is my cshtml
When I run my code on local host the table just flickers and disappears and also it fails to bind any data.
I'm using visual studio 2015 community and running on .NetCOre 1.0
I'm using Angular 1.5.7
I would appreciate any help.
My angular module declaration in apptrips.js:
(function () {
// Creating the Module
angular.module("apptrips", []);
})();
This is where the module is defined and a tripsController function is defined
Below i have the following console error in browser
O Uncaught Error: [Sinjector:nomod] http://errors.angul angular.is:2075 aris .org/1.5.7/Siniector/nomod?p0=app-trips at angular.is:38 at angular.~is:2075 at b (angular.is:1999) at Object.module (angular.is:2073) at tripsController.is:5 at tripsController.is: 14
© ► Error: [ng:areq] http://errors.angularis.org/1.5. angular.is:13708 7/ng/area?p0=tripsController&pl=not%20a%20function%2C%20got%20undefine d
at angular.is:38 at sb
(angular.is:1885) at Qa
(angular.is:1895) at
angular.is:10210 at ag
(angular.is:9331) at m
(angular.is:9116) at g
(angular.is:8510) at g
(angular.is:8513) at
angular.is:8390 at angular.is:1756
Error: [ng:areq] http://errors.angularis.org/1.5. angular.is:13708 7/ng/area?p0=tripsController&pl=not%20a%20function%2C%20got%20undefine d
Error indicates that the tripsController is not found/loaded.
Did you include the js file having the controller into your main index file?

angular_1.default.module Uncaught TypeError: Cannot read property 'module' of undefined

I am creating a starter template using angular 1.6, webpack, gulp and typescript. I am able to compile and build my application but app is not bootstrapping. The issue is weird as when I am debugging angular.module is defined and module can be created from console angular.module('testModule', []) but as resume debugger I get exception in core.module.ts at export const CoreModule = angular.module('app.core', []).name;.
I have further investigated this issue by disabling source code and I have found the problem. The above mentioned code compiles to exports.CoreModule = angular_1.default.module('app.core', []).name; where there is no property named default on angular_1.
For code refer https://github.com/muditsaurabh/awesome-ng-starter
Uncaught TypeError: Cannot read property 'module' of undefined
at Object.<anonymous> (app.bundle.js?cd4d443…:1)
at e (vendor.bundle.js?cd4d443…:1)
at Object.<anonymous> (app.bundle.js?cd4d443…:1)
at e (vendor.bundle.js?cd4d443…:1)
at Object.<anonymous> (app.bundle.js?cd4d443…:1)
at e (vendor.bundle.js?cd4d443…:1)
at window.webpackJsonp (vendor.bundle.js?cd4d443…:1)
at app.bundle.js?cd4d443…:1
vendor.bundle.js?cd4d443…:6Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.6.1/$injector/nomod?p0=app
at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:377
at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:11230
at n (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:10668)
at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:11004
at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:20796
at r (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:809)
at h (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:20644)
at le (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:22631)
at a (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:8560)
at st (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:8870)
http://errors.angularjs.org/1.6.1/$injector/modulerr?p0=app&p1=Error%3A%20%…2F%2Flocalhost%3A8000%2Fvendor.bundle.js%3Fcd4d4432605c6f5be56a%3A6%3A8870)
at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:377
at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:11230
at n (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:10668)
at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:11004
at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:20796
at r (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:809)
at h (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:20644)
at le (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:22631)
at a (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:8560)
at st (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:8870)
http://errors.angularjs.org/1.6.1/$injector/modulerr?p0=app&p1=Error%3A%20%…2F%2Flocalhost%3A8000%2Fvendor.bundle.js%3Fcd4d4432605c6f5be56a%3A6%3A8870)
at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:377
at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:21073
at r (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:809)
at h (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:20644)
at le (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:22631)
at a (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:8560)
at st (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:8870)
at at (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:8109)
at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:11:13916
at HTMLDocument.n (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:17809)
I have replaced import angular from 'angular' with import * as angular from 'angular' and now it is working fine.
Are you sure that AngularJS gets included before your script? The error means that the object angular hasn't been seen by Javascript yet and therefore module cannot be called on it.
You can also just add
"esModuleInterop": true,
to your tsconfig.json instead of using a star import everywhere.

How do I control the order files are loaded in karma config

I'm testing an Angular app with Karma. I've got everything working, but it seems like I'm doing something wrong.
https://gist.github.com/guyjacks/7bca850844deb612e681
Karma will throw the following error if I comment out 'app/notes/notes.main.js' :
Uncaught Error: [$injector:nomod] Module 'notes.main' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.4.3/$injector/nomod?p0=notes.main
at /Users/guyjacks/projects/adr-demo/node_modules/angular/angular.js:1958
I don't want to have to manually list each application file to control the order in which each file loads. Am I don't something wrong or do I just have to list each file in the order I want?
---- Solution based on the accepted answer ----
My app is organized into modules as recommended by the Angular Style Guide: https://github.com/johnpapa/angular-styleguide.
'app/app.module.js',
'app/**/*.module.js',
'app/**/*.service.js',
'app/**/*.controller.js',
'app/**/*.directive.js',
'app/**/*.js'
I don't think the following lines are necessary above
'app/**/*.service.js',
'app/**/*.controller.js',
'app/**/*.directive.js'
when each module has an angular module declared in the *.module.js file like my app does.
That said, if you did need to explicitly load services before controllers & controllers before directives then this would be the way to do it.
Update : I could not see your karma file, now Gist link is fixed.
The point in notes[.]main.js is causing the problem,
So, 'app/**/*.js' is not matching notes.main.js.
Try now like this : app/**/*. *.js
=============================================================
Before update :
You have to load the modules that you app depends on, in karma config. file :
module.exports = function(config) {
config.set({
.......
// list of files / patterns to load in the browser
files: [
'./client/app/vendors/angular/angular.js',
// =====> load Your modules here ...
'./client/app/app.js',
'./client/app/controllers/*.js',
'./client/app/directives/*.js',
'./client/app/services/*.js',
'./test/client/unit/**/*.js'
],
.....
}) }

jasmine-maven-plugin + phantomJS : Error: [$injector:nomod]

I create a project with :
mvn archetype:generate -DarchetypeGroupId=com.github.searls -DarchetypeArtifactId=jasmine-archetype -DarchetypeVersion=1.3.1.5 -DgroupId=com.acme -DartifactId=my-jasmine-project -Dversion=0.0.1-SNAPSHOT
First I test with mvn jasmine:test the test are run normally.
note : I use maven 3.2.1
In the "target" directory I add a folder "phantomjs-1.9.7-windows" where I put "phantomjs.exe"
I modifie my original pom.xml to add
...
<configuration>
<srcDirectoryName>${project.artifactId}/src/main/javascript</srcDirectoryName>
<webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
<webDriverCapabilities>
<capability>
<name>phantomjs.binary.path</name>
<value>${project.build.directory}/phantomjs-1.9.7-${os.phantomJS}/${run.phantomJS}</value>
</capability>
</webDriverCapabilities>
<preloadSources>
<source>${project.basedir}/src/main/javascript/libs/jquery-1.9.1.js</source>
<source>${project.basedir}/src/main/javascript/libs/angular.js</source>
<source>${project.basedir}/src/main/javascript/libs/angular-ui-router.js</source>
<source>${project.basedir}/src/main/javascript/libs/angular-resource.js</source>
</preloadSources>
</configuration>
...
I create a folder "libs" under "src/main/javascript" and I put in it :
- jquery-1.9.1.js
- angular.js
- angular-ui-router.js
- angular-resource.js
note : angular is in verion 1.2.23
After that I create an other folder "app" under "src/main/javascript" and I put in it : "app.module.js"
(function() {
'use strict';
angular.module('app', [
'app.Security.modules'
]);
})();
Under "src/main/javascript/app" I create a folder "security" and I put in it : "security.module.js"
(function() {
'use strict';
angular.module('app.Security.modules', []);
})();
and "cha_directive.js"
angular.module('app.Security.modules').directive('inputOld', InputAccessKeyManagement);
function InputAccessKeyManagement () {}
If I test with mvn jasmine:test I obtain an error :
[ERROR - 2015-02-26T08:12:49.751Z] Session [40eacc20-bd8f-11e4-a736-9934c466a5ff] - page.onError - stack:
(anonymous function) (http://localhost:51170/jasmine-project/src/main/javascript/libs/angular.js:1679)
ensure (http://localhost:51170/jasmine-project/src/main/javascript/libs/angular.js:1601)
module (http://localhost:51170/jasmine-project/src/main/javascript/libs/angular.js:1892)
(anonymous function) (http://localhost:51170/jasmine-project/src/main/javascript/app/security/cha_directive.js:1)
[WARNING] JavaScript Console Errors:
* Error: [$injector:nomod] Module 'app.Security.modules' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.2.23/$injector/nomod?p0=app.Security.modules
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.163s
[INFO] Finished at: Thu Feb 26 09:12:49 CET 2015
[INFO] Final Memory: 12M/210M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.searls:jasmine-maven-plugin:1.3.1.5:test (default-cli) on project jasmine-project: The jasmine-maven-plugin encountered an exception:
[ERROR] java.lang.RuntimeException: java.lang.RuntimeException: There were javascript console errors.
[ERROR] at com.github.searls.jasmine.runner.SpecRunnerExecutor.execute(SpecRunnerExecutor.java:46)
[ERROR] at com.github.searls.jasmine.mojo.TestMojo.executeSpecs(TestMojo.java:86)
If I just rename "cha_directive.js" in "toto_directive.js" (with the same source code) and I run mvn jasmine:test again the test are run normally.
If I use "cha_directive.js" name file and run mvn jasmine:bdd. After that I run the url http://localhost:8234 in FF the tests are run normally.
The only thing (if I edit the HTML code of "Jasmine Spec Runner" with fireBug) is that I can see this tag :
<head jmp_jserror="Error: [$injector:nomod] Module 'app.Security.modules' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://errors.angularjs.org/1.2.23/$injector/nomod?p0=app.Security.modules">
If I look in class SpecRunnerExecutor.java in "checkForConsoleErrors" there is a test :
WebElement head = driver.findElement(By.tagName("head"));
if (head != null) {
String jserrors = head.getAttribute("jmp_jserror");
if (StringUtils.isNotBlank(jserrors)) {
throw new RuntimeException("There were javascript console errors.");
}
}
note : other file name crash the tests : input_directive.js, accessKey_directive.js, ...
It is a problem of import script order.
I declare
(function() {
'use strict';
angular.module('app.Security.modules', []);
})();
in a file named "security.module.js"
and I try to use my declaration
angular.module('app.Security.modules')
.directive('inputOld', InputAccessKeyManagement);
function InputAccessKeyManagement () {}
in a file named "cha_directive.js"
If you don't specify a custom import script order the default one is alphabetical then "cha_directive.js" is before "security.module.js".
I solved the problem using a "customRunnerTemplate".
But maybe there was another way to do "prettier" ?
If anyone else comes across this, a good solution is to do something like this in your sourceInclude block:
<sourceInclude>
<include>**/*.module.js</include>
<include>**/*.controller.js</include>
<include>**/*.service.js</include>
...
Et cetera. Assuming you conform to having your modules defined in a file called something along the lines of 'example.module.js' the modules will be loaded first, then controller, et cetera

how to remove the module error while including?

Uncaught Error: [$injector:nomod] Module 'firstApp.seconddir' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second
here is my code
http://goo.gl/LOcYI2
I am getting error while including the module in our project.
You should register new module before you use it.
Setting module: angular.module('your new module name', [])
Getting module: angular.module('module name')
So in your case, change the following line and error will not come.
angular.module('firstApp.seconddir').config(Routes);
to
angular.module('firstApp.seconddir', []).config(Routes);
Working demo: http://goo.gl/RvHzqr

Resources