英文:
Is there a way I can get this package to work with Angular 16
问题
我已成功在一个Angular 10项目上使用了https://www.npmjs.com/package/ngx-hotjar v11.0.0包。我创建了一个新的Angular 16项目,但在运行ng serve时出现了以下错误:
错误:src/app/app.module.ts:275:12 - 错误NG6002:'NgxHotjarModule' 似乎不是一个NgModule类。
275 imports: [
~
276 BrowserModule,
~~~~~~~~~~~~~~~~~~
...
341 // SweetAlert2Module.forRoot()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
342 ],
~~~
node_modules/ngx-hotjar/lib/ngx-hotjar.module.d.ts:22:22
22 export declare class NgxHotjarModule {
~~~~~~~~~~~~~~~
这很可能意味着声明NgxHotjarModule的库(ngx-hotjar)与Angular Ivy不兼容。请检查库的新版本是否可用,并进行更新。还考虑与库的作者联系,看看该库是否预计与Ivy兼容。
错误:src/app/app.module.ts:337:5 - 错误NG6002:'NgxHotjarRouterModule' 似乎不是一个NgModule类。
337 NgxHotjarRouterModule,
~~~~~~~~~~~~~~~~~~~~~
node_modules/ngx-hotjar/lib/ngx-hotjar-router/ngx-hotjar-router.module.d.ts:29:22
29 export declare class NgxHotjarRouterModule {
~~~~~~~~~~~~~~~~~~~~~
这很可能意味着声明NgxHotjarRouterModule的库(ngx-hotjar)与Angular Ivy不兼容。请检查库的新版本是否可用,并进行更新。还考虑与库的作者联系,看看该库是否预计与Ivy兼容。
复现步骤:
创建一个新的Angular 16项目
npm i ngx-hotjar
**app.module.ts:**
import { NgxHotjarModule, NgxHotjarRouterModule } from 'ngx-hotjar';
imports: [... NgxHotjarModule.forRoot(environment.hj.trackingCode),
NgxHotjarRouterModule]
英文:
I have used the package https://www.npmjs.com/package/ngx-hotjar v11.0.0 successfully on an Angular 10 project. I have created a new Angular 16 project and I get the error below when running ng serve:
Error: src/app/app.module.ts:275:12 - error NG6002: 'NgxHotjarModule' does not appear to be an NgModule class.
275 imports: [
~
276 BrowserModule,
~~~~~~~~~~~~~~~~~~
...
341 // SweetAlert2Module.forRoot()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
342 ],
~~~
node_modules/ngx-hotjar/lib/ngx-hotjar.module.d.ts:22:22
22 export declare class NgxHotjarModule {
~~~~~~~~~~~~~~~
This likely means that the library (ngx-hotjar) which declares NgxHotjarModule is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
Error: src/app/app.module.ts:337:5 - error NG6002: 'NgxHotjarRouterModule' does not appear to be an NgModule class.
337 NgxHotjarRouterModule,
~~~~~~~~~~~~~~~~~~~~~
node_modules/ngx-hotjar/lib/ngx-hotjar-router/ngx-hotjar-router.module.d.ts:29:22
29 export declare class NgxHotjarRouterModule {
~~~~~~~~~~~~~~~~~~~~~
This likely means that the library (ngx-hotjar) which declares NgxHotjarRouterModule is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
To Reproduce
Create a new Angular 16 project
npm i ngx-hotjar
**app.module.ts:**
import { NgxHotjarModule, NgxHotjarRouterModule } from 'ngx-hotjar';
imports: [ ... NgxHotjarModule.forRoot(environment.hj.trackingCode),
NgxHotjarRouterModule]
答案1
得分: 3
这个库不支持Ivy和ViewEngine,从版本16开始不再支持。
所以答案是否定的,你将不得不分叉它。
英文:
The library isn't build for Ivy and ViewEngine support has been dropped in v16.
So the answer is no, you'll have to fork it.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论