我使用Reactjs和webpack来启动项目,当我在命令提示符下运行“node server”时,会出现如下错误:
而Chrome浏览器开通成功,但也有以下问题:
github是:(github.com/Yangqin0607/gallery)
这是package.json
{ "private": true,"version": "0.0.1","description": "YOUR DESCRIPTION - Generated by generator-react-webpack","main": "","scripts": { "clean": "rimraf dist/*","copy": "copyfiles -f ./src/index.html ./src/favicon.ico ./dist","dist": "npm run copy & webpack --env=dist","lint": "eslint ./src","posttest": "npm run lint","release:major": "npm version major && npm publish && git push --follow-tags","release:minor": "npm version minor && npm publish && git push --follow-tags","release:patch": "npm version patch && npm publish && git push --follow-tags","serve": "node server.js --env=dev","serve:dist": "node server.js --env=dist","start": "node server.js --env=dev","test": "karma start","test:watch": "karma start --autoWatch=true --singleRun=false" },"repository": "","keywords": [],"author": "Your name here","devDependencies": { "babel-core": "^6.0.0","babel-eslint": "^6.0.0","babel-loader": "^6.0.0","babel-polyfill": "^6.3.14","babel-preset-es2015": "^6.0.15","babel-preset-react": "^6.0.15","babel-preset-stage-0": "^6.5.0","bower-webpack-plugin": "^0.1.9","chai": "^3.2.0","copyfiles": "^1.0.0","css-loader": "^0.23.0","eslint": "^3.0.0","eslint-loader": "^1.0.0","eslint-plugin-react": "^6.0.0","file-loader": "^0.9.0","glob": "^7.0.0","isparta-instrumenter-loader": "^1.0.0","karma": "^1.0.0","karma-chai": "^0.1.0","karma-coverage": "^1.0.0","karma-mocha": "^1.0.0","karma-mocha-reporter": "^2.0.0","karma-phantomjs-launcher": "^1.0.0","karma-sourcemap-loader": "^0.3.5","karma-webpack": "^1.7.0","minimist": "^1.2.0","mocha": "^3.0.0","null-loader": "^0.1.1","open": "0.0.5","phantomjs-prebuilt": "^2.0.0","react-addons-test-utils": "^15.0.0","react-hot-loader": "^1.2.9","rimraf": "^2.4.3","style-loader": "^0.13.0","url-loader": "^0.5.6","webpack": "^1.12.0","webpack-dev-server": "^1.12.0" },"dependencies": { "core-js": "^2.0.0","normalize.css": "^4.0.0","react": "^15.0.0","react-dom": "^15.0.0" } }
此问题与反应热装载程序包有关。您正在使用依赖于node_modules / react / lib文件夹中的ReactMount.js文件的旧版本。
原文链接:https://www.f2er.com/react/301406.html没有一个简单的方法修复,但你有几个选项是:
>尝试按照这里的说明:https://github.com/gaearon/react-hot-loader/blob/master/docs/README.md#usage-with-external-react(但到目前为止我已经不幸了)
>删除热重新加载程序以进行反应(在您的webpack.config中删除“反应热”加载程序)
>将react-hot-loader包更新到版本3(这里是如何做的:https://github.com/gaearon/redux-devtools/commit/64f58b7010a1b2a71ad16716eb37ac1031f93915)。但请注意,这个包已经在alpha一段时间了…>将您的反应版本回滚到包含在lib文件夹中的ReactMount.js的版本(15.0.1用于使此文件停止时不确定)。