Я пытаюсь построить свое приложение, используя npm Запустить сборку .
Я получаю ошибку как TypeError: Cannot read property 'createContext' of undefined
.
Я внес следующие изменения после проверки решения
Я попытался обновить реакцию и реакцию dom на ^ 16.4 . По-прежнему получаю ту же ошибку.
Я определил в своем компоненте какact.default.createContext (). Я создал консоль в своем компоненте и обнаружил, что Resact.default не определен.
И это в этой части происходит ошибка.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = require("react");
const initStore = {
i18n: {},
query: {}
};
exports.AppContext = react_1.default.createContext(initStore);
exports.withAppContext = (Children) => {
return class App extends react_1.default.Component {
static async getInitialProps(ctx = {}) {
if (Children.hasOwnProperty('getInitialProps')) {
const context = Object.assign(ctx, {});
const childProps = (await Children.getInitialProps(context)) || {};
return Object.assign(childProps, {});
}
else {
return {};
}
}
render() {
return <exports.AppContext.Consumer>{app => <Child {...this.props} app={app}/>}</exports.AppContext.Consumer>;
}
};
};
Я поделился своим пакетом. 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"
}
}
Это какая-то проблема с версией? я использую Next js в качестве основы для реагирования также