错误在./~/react-tap-event-plugin/src/injectTapEventPlugin.js

Pro*_*rof 13 reactjs

在这里反应菜鸟.尝试克隆并运行https://github.com/strangebnb/react-airbnb

克隆.运行npm install.然后webpack,但我明白了

ERROR in ./~/react-tap-event-plugin/src/injectTapEventPlugin.js
Module not found: Error: Cannot resolve module 'react/lib/EventPluginHub' in /Users/thomas/tom/node_modules/react-tap-event-plugin/src
 @ ./~/react-tap-event-plugin/src/injectTapEventPlugin.js 23:2-37

ERROR in ./~/react-tap-event-plugin/src/TapEventPlugin.js
Module not found: Error: Cannot resolve module 'react/lib/EventConstants' in /Users/thomas/tom/node_modules/react-tap-event-plugin/src
 @ ./~/react-tap-event-plugin/src/TapEventPlugin.js 22:21-56

ERROR in ./~/react-tap-event-plugin/src/TapEventPlugin.js
Module not found: Error: Cannot resolve module 'react/lib/EventPluginUtils' in /Users/thomas/tom/node_modules/react-tap-event-plugin/src
 @ ./~/react-tap-event-plugin/src/TapEventPlugin.js 23:23-60

ERROR in ./~/react-tap-event-plugin/src/TapEventPlugin.js
Module not found: Error: Cannot resolve module 'react/lib/EventPropagators' in /Users/thomas/tom/node_modules/react-tap-event-plugin/src
 @ ./~/react-tap-event-plugin/src/TapEventPlugin.js 24:23-60

ERROR in ./~/react-tap-event-plugin/src/TapEventPlugin.js
Module not found: Error: Cannot resolve module 'react/lib/SyntheticUIEvent' in /Users/thomas/tom/node_modules/react-tap-event-plugin/src
 @ ./~/react-tap-event-plugin/src/TapEventPlugin.js 25:23-60

ERROR in ./~/react-tap-event-plugin/src/TapEventPlugin.js
Module not found: Error: Cannot resolve module 'react/lib/ViewportMetrics' in /Users/thomas/tom/node_modules/react-tap-event-plugin/src
 @ ./~/react-tap-event-plugin/src/TapEventPlugin.js 27:22-58

ERROR in ./~/react-portal/build/portal.js
Module not found: Error: Cannot resolve module 'react/lib/CSSPropertyOperations' in /Users/thomas/tom/node_modules/react-portal/build
 @ ./~/react-portal/build/portal.js 17:29-71
Run Code Online (Sandbox Code Playgroud)

我找到了https://github.com/thereactivestack/meteor-webpack/issues/21(我看到这是最近的,读到:昨天),在搞乱了我的packages.json之后,改变了反应,反应,材料-ui版本号和运行npm i --save react-tap-event-plugin,我得到'只'1错误消息

ERROR in ./~/react-portal/build/portal.js
Module not found: Error: Cannot resolve module 'react/lib/CSSPropertyOperations' in /Users/thomas/react-airbnb/node_modules/react-portal/build
 @ ./~/react-portal/build/portal.js 17:29-71
Run Code Online (Sandbox Code Playgroud)

我很新,我不知道如何解决这个问题.任何提示都非常受欢迎.

谢谢

小智 24

由于React中的更新,react-tap-event-plugin中断

如果使用react版本^ 15.4.0,请将package.json中的react-tap-event-plugin更改为^ 2.0.0.


Pan*_*ani 8

我把那个仓库分开并在我的仓库中解决了这个问题.另外,向原始仓库的所有者发送了拉取请求.这是我的分叉回购链接的链接:https: //github.com/pankajvishwani/react-airbnb

如果您不想克隆我的repo,可以在webpack.config.js中添加以下内容:

var reactDomLibPath = path.join(__dirname, "./node_modules/react-dom/lib");
var alias = {};
["EventPluginHub", "EventConstants", "EventPluginUtils", "EventPropagators",
 "SyntheticUIEvent", "CSSPropertyOperations", "ViewportMetrics"].forEach(function(filename){
    alias["react/lib/"+filename] = path.join(__dirname, "./node_modules/react-dom/lib", filename);
});

module.exports = {
  ...
  resolve: {alias: alias},
  ...
}
Run Code Online (Sandbox Code Playgroud)


Aik*_*y30 7

更新:从 React 16 开始,react-tap-event-plugin 已弃用,不再需要 https://www.npmjs.com/package/react-tap-event-plugin

从 React 16 开始,旧的解决方案是多余的 如果您使用的是 React 15.4.0,将 react tap 事件插件更新到 2.0.1 以上将解决您的问题。

一个新的 React 版本已经发布(https://github.com/facebook/react/blob/master/CHANGELOG.md),我最近读到有很大的变化,react-dom 仍然秘密地存在于 react 中包,但现在正在被删除。如果您阅读 15.4.0,第一点:'React 包和浏览器构建不再“秘密地”包含 React DOM。(@sebmarkbage 在 #7164 和 #7168 中)'

另请阅读点击事件插件 npm 文档:只有最新的点击事件插件(当前为 v2.0.1)支持 React 15.4+。https://www.npmjs.com/package/react-tap-event-plugin

检查 React 和 react-tap-event-plugin 的版本。npm 列表 --depth=0