Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

本地npm link调试ykfe-utils时报错 #36

Closed
zhangyuang opened this issue Jun 25, 2019 · 1 comment
Closed

本地npm link调试ykfe-utils时报错 #36

zhangyuang opened this issue Jun 25, 2019 · 1 comment

Comments

@zhangyuang
Copy link
Owner

image
使用npm link在本地调试ykfe-utils时报上图错误,但直接用npm install使用node_modules中的ykfe-utils无以上错误

@zhangyuang
Copy link
Owner Author

原因:由于我们在ykfe-utils中用到了withRouter这个方法,这个方法使用的时候上下文必须包含Router,我们在自己应用的entry.js中用browserRouter将其包裹,但在本地link开发时,ykfe-utils使用的react-router实例是自身的node_modules中的react-router。

解决方式: 保证全局只有一个react-router实例出现,使用webpack alias

// webpack.config.client.js
  resolve: {
    alias: {
      // for this issue https://github.com/ykfe/egg-react-ssr/issues/36
      'react-router': require.resolve('react-router')
    }
  },

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant