使用Next.js和Typescript初始化hotjar时的问题

xmq68pz9  于 2023-05-17  发布在  TypeScript
关注(0)|答案(1)|浏览(148)

我无法使用react-hotjar version 6.0.0在我的Next.js和TypeScript应用程序中初始化hotjar。
我的步骤包括:
在文件_app.tsx
我导入它使用

import { hotjar } from 'react-hotjar';

然后我在默认的function App中初始化它,如下所示:

useEffect(() => {
            hotjar.initialize(HJID, HJSV);
    }, [])

但当我奔跑

next build && next export

我收到以下错误:

Module parse failed: Identifier 'hotjar' has already been declared (11:13)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| ***
| 
> export const hotjar = ***
|   initialize: function initialize(id, sv) ***
|       hotjar(id, sv);
Import trace for requested module:
./node_modules/react-hotjar/index.js
> Build failed because of webpack errors

你知道失败的原因是什么吗?
或者,你能告诉我如何在TypeScript Next.js Web应用程序中初始化hotjar的资源吗?

i2loujxw

i2loujxw1#

今天也遇到了同样的问题,使用v6.1.0。降级到5.4.1似乎起作用了。

相关问题