ERROR in ./~/react-tap-event-plugin/src/injectTapEventPlugin.js

匿名 (未验证) 提交于 2019-12-03 02:29:01

问题:

React noob here. Trying to clone and run https://github.com/strangebnb/react-airbnb

I clone. run npm install. Then webpack but I get

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 

I found https://github.com/thereactivestack/meteor-webpack/issues/21 (I see this is very recent, read: yesterday), and after messing around with my packages.json, changing react, react-dom, material-ui version numbers and running npm i --save react-tap-event-plugin, I got down to 'only' 1 error message

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 

I'm pretty new and I'm not sure how to go about fixing this. Any hints greatly welcomed.

Thanks

回答1:

I forked that repo and fixed this issue in my repo. Also, sent pull request to the owner of original repo. Here's link to my forked repo: https://github.com/pankajvishwani/react-airbnb

If you don't want to clone my repo, you can add the following in 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},   ... } 


回答2:

Due to update in React, react-tap-event-plugin breaks

Change react-tap-event-plugin to ^2.0.0 in your package.json if using react version ^15.4.0.



回答3:

Resolving the dependency as Pankaj has stated is a hack.

Updating the react tap event plugin to over 2.0.1 will fix your issue if you're using React 15.4.0.

A new React version has been released (https://github.com/facebook/react/blob/master/CHANGELOG.md), and I read recently that there have been big changes where react-dom still secretly lived on in the react package but is now being removed. If you read 15.4.0, the first point: 'React package and browser build no longer "secretly" includes React DOM. (@sebmarkbage in #7164 and #7168)'

Also reading the tap event plugins npm docs: Only the latest tap event plugin (v2.0.1 currently) supports React 15.4+. https://www.npmjs.com/package/react-tap-event-plugin

I was also experiencing the same and fell on this post. I have solved the issue on my machine.

Check the version of React and react-tap-event-plugin.

npm list --depth=0 


回答4:

In the short term, you could fix React to a specific earlier version.

If your package.json file contains something like: "react": "^15.3.2", in the dependencies section, you could change it to say "react": "=15.3.2”,



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!