klover2 / wechatpay-node-v3-ts

微信支付v3
MIT License
528 stars 82 forks source link

hexoid is not a function #61

Closed evanlong0803 closed 8 months ago

evanlong0803 commented 8 months ago

image

这是为什么?

evanlong0803 commented 8 months ago

没事了,这是 Nextjs 框架的问题

kumv-net commented 7 months ago

没事了,这是 Nextjs 框架的问题

什么问题导致的,怎么解决,今天配置热更新遇到了

guojingwen commented 6 months ago

没事了,这是 Nextjs 框架的问题

我也遇到了。楼主怎么解决的

guojingwen commented 6 months ago

按照 https://github.com/auth0/node-auth0/issues/798 这个

pkg文件增加配置 resolve: { alias: { "superagent": "6.0.0" } } } 使用yarn 安装 解决了, 不知道后续会不会有什么副作用

evanlong0803 commented 5 months ago

按照 auth0/node-auth0#798 这个

pkg文件增加配置 resolve: { alias: { "superagent": "6.0.0" } } } 使用yarn 安装 解决了, 不知道后续会不会有什么副作用

大概率是包导出时写法的问题,包中可能使用了一个表达式。而在某些框架中对表达式不是很敏感

hevi1991 commented 5 months ago

我从nextjs13升级到14版本后,也报了这个异常

我的解决办法是:

next.config.mjs 配置中,添加 webpack 在 server 模式下的别名

/** @type {import('next').NextConfig} */
const nextConfig = {
 ...,
  webpack: (config, { isServer }) => {
    if (isServer) {
      return {
        ...config,
        resolve: {
          ...config.resolve,
          alias: { ...config.resolve.alias, hexoid: "hexoid/dist/index.js" },
        },
        // 引入微信支付相关包后,警告【Critical dependency: the request of a dependency is an expression】关闭
        module: { ...config.module, exprContextCritical: false },
      };
    }
    return config;
  },
};

export default nextConfig;
madrus commented 5 months ago

Thank you @hevi1991 ! Your suggestion helped me to fix this error in my Nextjs v14 project.