TypeError:无法读取未定义的属性'createContext'

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TypeError:无法读取未定义的属性'createContext'相关的知识,希望对你有一定的参考价值。

我正在尝试使用npm run build来构建我的应用程序。

我得到的错误是TypeError: Cannot read property 'createContext' of undefined

检查解决方案后,我进行了以下更改

我尝试将反应并反应dom升级到^ 16.4。仍然出现相同的错误。

我在组件中定义为react.default.createContenxt()我在组件中做了一个控制台,发现react.default是未定义的。

我在下面共享了我的package.json文件

{
  "name": "next-web",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "browser": {
    "fs": false,
    "child_process": false,
    "fork": false
  },
  "fork": false,
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start",
    "test": "echo "Error: no test specified" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@types/react-transition-group": "^4.2.3",
    "alertifyjs": "^1.13.1",
    "apollo-cache-inmemory": "^1.6.5",
    "apollo-client": "^2.6.8",
    "apollo-link": "^1.2.13",
    "apollo-link-context": "^1.0.19",
    "apollo-link-error": "^1.1.12",
    "apollo-link-http": "^1.5.16",
    "apollo-link-retry": "^2.2.15",
    "apollo-link-timeout": "^1.4.0",
    "apollo-link-ws": "^1.0.19",
    "apollo-utilities": "^1.3.3",
    "aws-xray-sdk-core": "^2.5.0",
    "babel-plugin-root-import": "^6.4.1",
    "child_process": "^1.0.2",
    "crypto-js": "^3.1.9-1",
    "ctrip-apollo": "^4.4.3",
    "date-fns": "^2.9.0",
    "fs": "0.0.1-security",
    "graphql": "^14.6.0",
    "graphql-hooks-memcache": "^1.3.1",
    "graphql-tag": "^2.10.1",
    "isomorphic-fetch": "^2.2.1",
    "jquery-param": "^1.0.2",
    "js-cookie": "^2.2.1",
    "koa": "^2.11.0",
    "koa-bodyparser": "^4.2.1",
    "koa-router": "^8.0.6",
    "memcached": "^2.2.2",
    "next": "^9.0.1",
    "next-config": "^0.1.0",
    "next-routes": "^1.4.2",
    "next-server": "^9.0.5",
    "polished": "^3.4.4",
    "qrcode": "^1.4.4",
    "react": "^16.12.0",
    "react-adopt": "^0.6.0",
    "react-apollo": "^3.1.3",
    "react-app-rewired": "^2.1.5",
    "react-copy-to-clipboard": "^5.0.2",
    "react-day-picker": "^7.4.0",
    "react-dnd": "^10.0.2",
    "react-dnd-html5-backend": "^10.0.2",
    "react-dom": "^16.12.0",
    "react-lazyload": "^2.6.5",
    "react-progressive-image": "^0.6.0",
    "react-slick": "^0.25.2",
    "react-transition-group": "^4.3.0",
    "styled-components": "^5.0.0",
    "styled-tools": "^1.7.1",
    "subscriptions-transport-ws": "^0.9.16",
    "ua-parser-js": "^0.7.21",
    "webpack-node-externals": "^1.7.2",
    "ycb": "^2.1.1"
  },
  "devDependencies": {
    "babel-preset-es2015": "^6.24.1",
    "react-dev-utils": "^10.1.0"
  }
}

是某种版本的问题吗?即时通讯还使用Nextjs作为框架进行反应

以上是关于TypeError:无法读取未定义的属性'createContext'的主要内容,如果未能解决你的问题,请参考以下文章

TypeError:无法读取未定义的属性'map'| ReactJS

karma TypeError“无法读取未定义的属性'subscribe'”

未捕获的TypeError:无法读取未定义的属性'ajax'

TypeError:无法读取未定义的属性'createContext'

“错误TypeError:无法读取未定义的属性'name'” Angular

Nativescript 5.3.1 TypeError:无法读取未定义的属性'getViewById'