未捕获的类型错误

未捕获的类型错误

本文介绍了未捕获的类型错误:无法读取未定义的 react-dom.production.min.js:760 的属性“hasOwnProperty"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

当我尝试打开我的构建项目时出现此错误

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)

产生错误的第 760 行.注意变量 aa 是 require("react");

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
});

这是我的 package.json,你会注意到我使用的是最新版本的 React 和 React-Dom

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

index.html generated by the build

https://pastebin.com/zUWitJH2

推荐答案

我遇到了这个问题,花了两个小时浏览网页.

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

然后我做了一个npm list |grep react 并意识到 reactreact-dom 有不同的版本.package.json 仅指定版本范围,但不保证它们运行在同一版本上.

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.

所以我所做的是 npm rm react react-dom &&npm i -s react react-dom.

现在他们有相同的版本,终于可以一起工作了.

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

这篇关于未捕获的类型错误:无法读取未定义的 react-dom.production.min.js:760 的属性“hasOwnProperty"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 13:08