TypeError: can't convert undefined to object - connectMenu.js:81. Only in production env #284
Comments
Fixed issue by excluding node_modules From Being Transpiled By Babel-Loader. If your using Webpacker for Rails add this line
|
@meetajhu How to solve the problem without using Webpacker for Rails |
in your webpack.config.js add "exclude: /(node_modules)/" under your babel-loader settings
|
@meetajhu I found some other solutions 1. change the react-contextmenu's package.json 2. delete "module": "es6/index.js" of the react-contextmenu's package.json 3. change wepack.config.js like this resolve: {
mainFields: ['main', 'module']
} |
These "solutions" are not easy to implement in every situation. I tried both and they did not work for me. I had to revert to copying the And my case will not be rare: It seems that this problem occurs when this lib is used in gatsby (my case). Which is quite popular. So I feel that this issue should be re-opened. |
@eyelly-wu I have to admit I do not completely understand your solution. Do you think this could be converted into a pull request? Hoping it would be accepted? |
Why is this issue closed? The same bug still appears for me in Gatsby |
This bug is also appearing for me in Gatsby. UPDATE: It turns out react-contextmenu was breaking my gatsby build causing the error In my case, /app/ is a client-only route that contains a client-side react app. I had no problems when I run My temporary solution for now is to use the compiled version of react-contextmenu in So instead of Thanks to @barbalex for your comments above and also in the gatsby issues, they helped me find the solution. I do think that this bug should be reopened and addressed – I suspect that a number of people out there are using gatsby with react-contextmenu and will run into this problem. |
Version
v2.11.0
Test Case
Steps to reproduce
Take Webpack build with
NODENV=Production
and run the react app. Browser console shows error inconnectMenu.js:81 TypeError: can't convert undefined to object
. Development environment works fine.Expected Behavior
Not sure if Babel related error. But app should run in Production build.
Actual Behavior
Everything is fine on development environment. However, when I compile my packs to production-ready environment (NODE_ENV=production), react-contextmenu gives an error on startup in file
connectMenu.js:81
The text was updated successfully, but these errors were encountered: