Setting up ng-jhipster on a generated JHipster app

末鹿安然 提交于 2019-12-11 02:08:47

问题


I would like to configure a cloned ng-jhipster project as a dependency for a generated JHipster app.

I'm using the following versions (from jhipster info):

git version 2.15.0  
node: v6.11.5  
npm: 5.4.2  
yarn: 1.2.1  
yeoman: 2.0.0  

For my new generated JHipster application, I'm doing the following steps:
yarn global add generator-jhipster (I get v4.10.2)
mkdir ~/v4.10.2
cd ~/myNewGeneratedApp
jhipster: here I choose all the defaults (specially Angular 4)
(yarn install is automatically executed and everything is fine)
Then I run yarn start and everything is starting well.

For my ng-jhipster, I'm doing the following steps:
cd ~
git clone https://github.com/jhipster/ng-jhipster
cd ng-jhipster
git checkout v0.2.12 (to use the "same" dependency version from myNewGeneratedApp)

Now I'm reading the ng-jhipster wiki and I run:

yarn install
yarn run test  
yarn run build  
yarn link

I go back to myNewGeneratedApp folder:

cd ~/myNewGeneratedApp 
yarn link ng-jhipster 

So in ~/myNewGeneratedApp/node_modules, the folder ng-jhipster is well link to my local ng-jhipster project.

Now when I run yarn start and I have the following errors:

ERROR in [at-loader] ./src/main/webapp/app/blocks/interceptor/auth-expired.interceptor.ts:7:14
        TS2415: Class 'AuthExpiredInterceptor' incorrectly extends base class 'JhiHttpInterceptor'.
      Types of property 'requestIntercept' are incompatible.
        Type '(options?: RequestOptionsArgs) => RequestOptionsArgs' is not assignable to type '(options?: RequestOptionsArgs) => RequestOptionsArgs'. Two different types with this name exist, but they are unrelated.
          Types of parameters 'options' and 'options' are incompatible.
            Type 'RequestOptionsArgs' is not assignable to type 'RequestOptionsArgs'. Two different types with this name exist, but they are unrelated.

ERROR in [at-loader] ./src/main/webapp/app/blocks/interceptor/auth.interceptor.ts:6:14
        TS2415: Class 'AuthInterceptor' incorrectly extends base class 'JhiHttpInterceptor'.
      Types of property 'requestIntercept' are incompatible.
        Type '(options?: RequestOptionsArgs) => RequestOptionsArgs' is not assignable to type '(options?: RequestOptionsArgs) => RequestOptionsArgs'. Two different types with this name exist, but they are unrelated.
          Types of parameters 'options' and 'options' are incompatible.
            Type 'RequestOptionsArgs' is not assignable to type 'RequestOptionsArgs'. Two different types with this name exist, but they are unrelated.

ERROR in [at-loader] ./src/main/webapp/app/blocks/interceptor/errorhandler.interceptor.ts:5:14
        TS2415: Class 'ErrorHandlerInterceptor' incorrectly extends base class 'JhiHttpInterceptor'.
      Types of property 'requestIntercept' are incompatible.
        Type '(options?: RequestOptionsArgs) => RequestOptionsArgs' is not assignable to type '(options?: RequestOptionsArgs) => RequestOptionsArgs'. Two different types with this name exist, but they are unrelated.
          Types of parameters 'options' and 'options' are incompatible.
            Type 'RequestOptionsArgs' is not assignable to type 'RequestOptionsArgs'. Two different types with this name exist, but they are unrelated.

ERROR in [at-loader] ./src/main/webapp/app/blocks/interceptor/http.provider.ts:20:9
        TS2345: Argument of type 'XHRBackend' is not assignable to parameter of type 'ConnectionBackend'.
      Types of property 'createConnection' are incompatible.
        Type '(request: Request) => XHRConnection' is not assignable to type '(request: any) => Connection'.
          Type 'XHRConnection' is not assignable to type 'Connection'.
            Types of property 'request' are incompatible.
              Type 'Request' is not assignable to type 'Request'. Two different types with this name exist, but they are unrelated.
                Types of property 'headers' are incompatible.
                  Type 'Headers' is not assignable to type 'Headers'. Two different types with this name exist, but they are unrelated.
                    Types have separate declarations of a private property 'mayBeSetNormalizedName'.

ERROR in [at-loader] ./src/main/webapp/app/blocks/interceptor/notification.interceptor.ts:6:14
        TS2415: Class 'NotificationInterceptor' incorrectly extends base class 'JhiHttpInterceptor'.
      Types of property 'requestIntercept' are incompatible.
        Type '(options?: RequestOptionsArgs) => RequestOptionsArgs' is not assignable to type '(options?: RequestOptionsArgs) => RequestOptionsArgs'. Two different types with this name exist, but they are unrelated.
          Types of parameters 'options' and 'options' are incompatible.
            Type 'RequestOptionsArgs' is not assignable to type 'RequestOptionsArgs'. Two different types with this name exist, but they are unrelated.
              Types of property 'headers' are incompatible.
                Type 'Headers' is not assignable to type 'Headers'. Two different types with this name exist, but they are unrelated.
                  Types have separate declarations of a private property 'mayBeSetNormalizedName'.

ERROR in [at-loader] ./src/main/webapp/app/shared/alert/alert-error.component.ts:25:9
        TS90010: Type 'Subscription' is not assignable to type 'Subscription'. Two different types with this name exist, but they are unrelated.
      Property '_parent' is protected but type 'Subscription' is not a class derived from 'Subscription'.

ERROR in [at-loader] ./src/main/webapp/app/shared/alert/alert-error.component.ts:86:39
        TS2345: Argument of type 'Subscription' is not assignable to parameter of type 'Subscription'.
      Property '_parent' is protected but type 'Subscription' is not a class derived from 'Subscription'.

If I "revert" this step by doing:
yarn add ng-jhipster
yarn start -> everything is fine (using the real NPM dependency)

I noticed some differences between the ng-jhipster locally linked and the one that yarn gets from NPM repo: With the locally linked project:
- The node_modules folder exists in myNewGeneratedApp/node_modules/ng-jhipster
- There is no '.js' files. (the typescript transpilation has not been executed)
- So there are still the *.ts files

I don't know if this is abnormal but with the dependency from NPM repo (which is working well) differs (at least) with the above points.
Maybe the release script from ng-jhipster need to be run as well (?). (for npm run ngc and npm publish steps ?)
Did I missed something the the process ? maybe there is just a missing step in the wiki ?

It is somehow related with this issue: ng-jhipster development creates compilation errors. And the steps described didn't work for me.

Thanks for your help !


回答1:


check the readme in ng-jhipster project here: https://github.com/jhipster/ng-jhipster/blob/master/README.md




回答2:


So what we can do on ng-jhipster project:

yarn ngc
yarn pack

and then from your generated JHipster application the following commands:

git checkout -- yarn.lock 
yarn cache clean ng-jhipster 
rm -rf `yarn cache dir`/.tmp 
yarn add path/to/ng-jhipster/ng-jhipster-vX.Y.Z.tgz


来源:https://stackoverflow.com/questions/47085623/setting-up-ng-jhipster-on-a-generated-jhipster-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!