【问题标题】:Node module (@pusher/push-notifications-web) failing to import on refreshing page - nextjs节点模块(@pusher/push-notifications-web)无法在刷新页面上导入 - nextjs
【发布时间】:2021-04-26 17:09:46
【问题描述】:

在集成节点模块时遇到这个问题@pusher/push-notifications-webhttps://github.com/pusher/push-notifications-web

我不确定这是 NextJs 还是节点模块本身的问题。

页面第一次加载时一切正常,但如果我们刷新页面或将用户重定向到新页面时。我收到此错误

【问题讨论】:

标签: javascript node.js reactjs next.js pusher


【解决方案1】:

可以通过在 Next.js 配置中使用 next-transpile-modules 转译 @pusher/push-notifications-web 模块(导出为 ESM)来解决此问题:

// next.config.js
const withTM = require('next-transpile-modules')(['@pusher/push-notifications-web']);

module.exports = withTM({/* custom config */});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-29
    • 1970-01-01
    • 2020-10-31
    • 2019-07-15
    • 1970-01-01
    • 2020-12-23
    • 2019-08-19
    相关资源
    最近更新 更多