Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: Cannot read property 'hasOwnProperty' of undefined react-dom.production.min.js:760

I'm getting this error when I try to open my build project

by the way the project works fine in development mode.

Uncaught TypeError: Cannot read property 'hasOwnProperty' of undefined
    at Object.<anonymous> (react-dom.production.min.js:760)
    at m (bundle.js:1)
    at Object.<anonymous> (index.js:34)
    at m (bundle.js:1)
    at Module.56 (main.2b9897ed.chunk.js:1)
    at m (bundle.js:1)
    at Object.36 (main.2b9897ed.chunk.js:1)
    at m (bundle.js:1)
    at l (bundle.js:1)
    at Array.n (bundle.js:1)

Line 760 that generates the error. Note that the variable aa is require("react");

var Tb = aa.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
Tb.hasOwnProperty("ReactCurrentDispatcher") || (Tb.ReactCurrentDispatcher = {
  current: null
});

here is my package.json, as you notice I use the last version of React and React-Dom

{
  "name": "xxxx",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.8.6",
    "react-confirm-alert": "^2.4.1",
    "react-dom": "^16.8.6",
    "react-redux": "^7.0.2",
    "react-router-dom": "^5.0.0",
    "react-scripts": "2.1.8",
    "redux": "^4.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "proxy": "http://localhost:3001",
  "devDependencies": {
    "datatables.net": "^1.10.19",
    "jquery": "^3.4.0"
  }
}

index.html generated by the build

https://pastebin.com/zUWitJH2

like image 523
Anas M K Avatar asked May 06 '19 10:05

Anas M K


1 Answers

I had this problem, and spent two hours browsing the web.

Then I did a npm list | grep react and realized react and react-dom had a different version. The package.json only specify version ranges, but doesn't guarantee they run at the same version.

So what I did is npm rm react react-dom && npm i -s react react-dom.

Now they have the same version, and finally work together.

like image 167
OoDeLally Avatar answered Nov 15 '22 10:11

OoDeLally