首页 > 解决方案 > 我如何告诉 Webpack 只/总是使用包 json 中显示的版本?

问题描述

我正在尝试为 npm 包(react-draft-wysiwyg)做出贡献,但不断收到(我认为是)Webpack 错误。

首先,我尝试单击 Draft-js 的嵌入按钮,但它错误地说“块不是 BlockNode” - 然后我关注这样的博客/帖子https://github.com/facebook/draft-js/issues/1763 我将对等依赖项和主项目 pkg json 依赖项匹配到 Draft-js v0.10.4,重新纱线,它说

Element ref was specified as a string (editorContainer) but no owner was set. This could happen for one of the following reasons:

1. You may be adding a ref to a function component
2. You may be adding a ref to a component that was not created inside a component's render method
3. You have multiple copies of React loaded

所以在我的项目的 webpack.config.js 我有:

alias: {
        react: path.resolve('node_modules/react'),
        modules: [path.resolve(__dirname, "app"), "node_modules"],
      },

我真的认为这些问题源于网络应用程序试图从本地纱线链接中提取不同版本的反应。

我如何告诉 Webpack 只使用顶层,而不是其他所有东西?

帮助?

标签: javascriptwebpackwebpack-dev-serverdraftjs

解决方案


推荐阅读