Question
What do I need to do to get basename defined in JHipster's spring-controller generation?
Problem
I'm attempting to use JHipster to generate a spring-controller. It fails to generate, giving the stacktrace copied below. Further investigation shows that this is crashing because basename is undefined (module.exports.getAngularAppName needs basename to have a value).
Other JHipster generators (gateway, microservice, monolith, spring-service) are working fine, so it's not a general configuration issue.
I've tried adding getTheModuleName() from similarly patterned JHipster generators to spring-controller/prompts.js, but it doesn't work because this.getModuleName() doesn't exist. I can't find where getModuleName() IS defined, nor do I understand what "this" is within prompts.
I'm a JHipster noob so I'm assuming I'm missing something simple.
Any help would be appreciated.
Version info
JHipster Generator v4.13.0
nodejs 8.9.3
Fresh installs from nodejs on up as of yesterday
Other JHipster generators are working fine, so it's not a general configuration issue.
Inputs/outputs
C:\yesOnWindows>jhipster spring-controller fum
Using JHipster version installed globally
Executing jhipster:spring-controller fum
Options:
The spring-controller fum is being created.
? Do you want to add an action to your controller? Yes
? What is the name of your action? fff
? What is the HTTP method of your action? GET
? Do you want to add an action to your controller? No
events.js:183
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'endsWith' of undefined
at module.exports.getAngularAppName (C:\Users\Dad\nodejs\node_modules\generator-jhipster\generators\generator-base.js:2090:56)
at module.exports.getMainClassName (C:\Users\Dad\nodejs\node_modules\generator-jhipster\generators\generator-base.js:2113:40)
at module.exports.writing (C:\Users\Dad\nodejs\node_modules\generator-jhipster\generators\spring-controller\index.js:83:31)
at Object.<anonymous> (C:\Users\Dad\nodejs\node_modules\generator-jhipster\node_modules\yeoman-generator\lib\index.js:399:25)
at C:\Users\Dad\nodejs\node_modules\generator-jhipster\node_modules\yeoman-generator\node_modules\run-async\index.js:25:25
at new Promise (<anonymous>)
at C:\Users\Dad\nodejs\node_modules\generator-jhipster\node_modules\yeoman-generator\node_modules\run-async\index.js:24:19
at self.env.runLoop.add.completed (C:\Users\Dad\nodejs\node_modules\generator-jhipster\node_modules\yeoman-generator\lib\index.js:400:11)
at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
The JHipster spring generators are intended to be used in a generated JHipster project. The generator reads the baseName property from the project's .yo-rc.json file (for example here). Without first generating a project, JHipster won't be able to generate a Java file that compiles.
Related
I hope I'm in the right place.
We have a problem with our website. We only got files and a database from the previous admin. I uploaded them to the server and the site is partially working.The problem arises when we click one of the links to articles on the site. The place where the article should be placed is empty. The console in chrome says:
TypeError: Cannot read properties of undefined (reading 'date')
at Cn.eval (eval at Qa (vue.js:6:92206), <anonymous>:3:386)
at e._render (vue.js:6:35554)
at Cn.r (vue.js:6:68565)
at pn.get (vue.js:6:26867)
at pn.run (vue.js:6:27751)
at ln (vue.js:6:25859)
at Array.<anonymous> (vue.js:6:12476)
at We (vue.js:6:11877)
and a warning:
"DevTools failed to load source map: Could not load content for https://example.com/js/axios.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE"
I read about it on stack and other pages and it seams that the variables aren't defined.
It was working on the previous server. :(
As I understand it, when I copied the files and the database and installed all the dependencies it should work? Or is there anything that I'm missing?
I think that connection with database works, other parts of the website are working and some of the data for the website is working fine.
It seams like there is something missing, but I have no idea what.
Can it be that because of the missing axios.map file the js can't define some of the variables on the website?
What could have caused it during the transfer? Some files missing? collection error in mongodb?
I'm struggling for over a week now, and I ran out of ideas for the moment...
Is there any way I can debug it?
I'm not a js programmer but a simple admin and I'm getting kind of confused. Has anyone had such a problem?
If anyone needs any more info please let me know.
What I did:
installed nodejs via nvm install 12.18.4 //it's the version on which it was working earlier, on previous server
installed mongo and imported collections to the database in json format
installed and configured nginx to handle the request foe the website
deleted the modules folder and npm install'ed them again
A Brief Backstory
I have been implementing several upgrades to an Angular 8 application such as server-side rendering, and Google Analytics. As most developers do, I would code then test then move on to the next task. Typically I use ng serve to run the application as I am developing.
With Server-side rendering, to test speed, lazy-loaded images, etc, you need to use a node express server running on a generated JS file. After building, etc, I use Node prerender (my js file is prerender.js) to see what the application will look like prerendering on the server.
When I run this command, I should not get any errors, and I know my prender file will start a local server on port 4000.
The Problem
I get errors when running a node express server that I do not get when running with ng serve I recently got an error that said:
Unhandled Promise rejection: Cannot read property 'subscribe' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'subscribe' of undefined
at new ApplicationRef (C:\4towerdevelopment\dist-stage\server\main.js:45910:37)
at _createClass (C:\4towerdevelopment\dist-stage\server\main.js:37184:20)
at _createProviderInstance (C:\4towerdevelopment\dist-stage\server\main.js:37138:26)
at initNgModule (C:\4towerdevelopment\dist-stage\server\main.js:37044:32)
at new NgModuleRef_ (C:\4towerdevelopment\dist-stage\server\main.js:38176:9)
at Object.createNgModuleRef (C:\4towerdevelopment\dist-stage\server\main.js:38159:12)
at NgModuleFactory_.create (C:\4towerdevelopment\dist-stage\server\main.js:50821:25)
at C:\4towerdevelopment\dist-stage\prerender.js:29175:43
at ZoneDelegate.invoke (C:\4towerdevelopment\dist-stage\prerender.js:481:26)
at Object.onInvoke (C:\4towerdevelopment\dist-stage\prerender.js:28683:33) TypeError: Cannot read property 'subscribe' of undefined
at new ApplicationRef (C:\4towerdevelopment\dist-stage\server\main.js:45910:37)
at _createClass (C:\4towerdevelopment\dist-stage\server\main.js:37184:20)
at _createProviderInstance (C:\4towerdevelopment\dist-stage\server\main.js:37138:26)
at initNgModule (C:\4towerdevelopment\dist-stage\server\main.js:37044:32)
at new NgModuleRef_ (C:\4towerdevelopment\dist-stage\server\main.js:38176:9)
at Object.createNgModuleRef (C:\4towerdevelopment\dist-stage\server\main.js:38159:12)
at NgModuleFactory_.create (C:\4towerdevelopment\dist-stage\server\main.js:50821:25)
at C:\4towerdevelopment\dist-stage\prerender.js:29175:43
at ZoneDelegate.invoke (C:\4towerdevelopment\dist-stage\prerender.js:481:26)
at Object.onInvoke (C:\4towerdevelopment\dist-stage\prerender.js:28683:33)
The closest this gets me to figuring what actually is causing the problem is letting me know that a provider somewhere is causing this error. Looks like something should be an observable rather than a subscription. Beyond that, I guess I just start looking through my providers. My question is:
How can I force Angular to possibly throw this error when developing using ng serve?
If I can't, is there a better way to debug this current error besides combing through each provider? Or at least a way to tell what service is causing the issue?
Thank you.
UPDATE: Basic repo with problem here. I made a new angular project, made sure dependencies were up to date, installed ngUniversal per this post, and received this same Unhandled promise message when running node prerender
Verbatim I went to to the Angular cli website, made a new project (default Angular version installed was 8.3), installed Angular Universal, and tried to build. Same error message as above.
This looks like it was ApplicationRef that triggered the error, and that class is provided internally by the Angular core.
It could be failing in the constructor of the class, and there are a few calls to subscribe on Zone observables. I don't think you're going to find anything in your source code that directly relates to this error. It looks like a build configuration problem.
https://github.com/angular/angular/blob/bb52fb798c8578c461d21aee2b7623232184a5d3/packages/core/src/application_ref.ts#L562
I do not know what could possibly produce this problem, but I would start a new project with SSR and compare the differences to your current project.
Eventually, I dropped the angular 6 approach using pre-render, and went with the latest universal package. There seems to be no problem building using npm run build:ssr and serving dist/server.js in an express server. I am not sure what the problem was with the pre-render approach, but it seems to be outdated anyways. #Reactgular thanks for the feedback.
I am just a newbie in mean.io . I want to build an event module just like the post which can be found the default module when you make an installation. I have taken everything from the post and renamed it as event. Now when I am trying to insert a new record in the event schema its showing an error like
there was an error sending the query Error: GraphQL error: Unknown type "EventInput". Did you mean "PostInput"?
GraphQL error: Cannot query field "addEvent" on type "Mutation". Did you mean "addPost"?
So can someone tell me what I am doing wrong here? Any suggestion or help will be really appreciable.
The problem is with innograph.
The addPost is coming from this npm module and not the actual /server/ changes that you have made.
innograph is initialised in express.js
The solution is to copy the innograph code into you application. Make all the changes and actually remove innograph from package.json.
If its too much just remove innograph, graphql, apollo packages and then simply use express.js that is also pre-built into mean.io.
The second step requires changes to be made into /server/ folder. I had to do some debugging to actually make it work.
I am using angular-cli for a MEAN stack application. It was working fine till yesterday, but today I am getting,
WARNING in ./~/mongoose/lib/drivers/index.js
8:11-74 Critical dependency: the request of a dependency is an expression
on ng build.
And if i still proceed and run the application i get,
Uncaught TypeError: __webpack_require__.i(...) is not a function
at Object.260 (main.bundle.js:913)
at __webpack_require__ (inline.bundle.js:53)
at Object.142 (main.bundle.js:11)
error on,
var User = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mongoose__["model"])("User", UserSchema);
in main bundle.
My ts file where this code is,
export const User: Model<IUser> = model<IUser>("User", UserSchema);
I searched on net and tried many things but had no luck.
Also some posts are suggesting to run web pack,but this was working till yesterday where I had no web pack.
I also hardcoded the mongoose's version value by removing caret from pacakge.json, had no luck again.
I made a different typescript class for entity model that is to be used on UI(angular 2) side.
Earlier was using the schema class as model in my UI too, hence was getting this error.
I'm working migrating a bunch of unit tests from mockery to jest. When I jest a module that requires the new relic agent like so: require('newrelic'), I get downstream errors like :
- TypeError: Cannot convert undefined or null to object
at Object.<anonymous> (node_modules/newrelic/lib/config.js:165:33)
at Runtime._execModule (node_modules/jest-cli/src/Runtime/Runtime.js:261:17)
at Object.<anonymous> (node_modules/newrelic/lib/logger.js:18:14)
at Object.<anonymous> (node_modules/newrelic/index.js:3:14)
What is the best way to deal with modules like newrelic which jest has a hard time mocking? What have other people done when they have both jest and newrelic in their stack?
The route I ended up taking was to create a mock module for newrelic in my __mocks__ folder:
module.exports = {
addCustomParameter: jest.fn()
};
I will probably need to add more functions later, but for now this is enough. I still wonder if there is a way to get jest to auto mock the newrelic library without erroring.
I've seen this with a few modules were automocking fails for various reasons, although it seems to happen a lot less frequently in the newer versions of Jest.
As #linuxdan suggests you might be able to work around the issue by using the manual mocking functionality documented here.
To so this you'll probably want to just export an object with the expected methods generated using jest.fn().
The reason this will work is it will stop jest trying to determine the methods it needs to auto mock on the newrelic library. It will be during this process that it fails.