gpt4 book ai didi

reactjs - "module not found : Error: Cannot resolve module ' react /lib/ReactMount ' "

转载 作者:行者123 更新时间:2023-12-03 13:03:18 29 4
gpt4 key购买 nike

我使用Reactjs和webpack启动一个项目,当我在命令提示符中运行“node server”时,出现如下错误:

enter image description here

并且chrome浏览器打开成功但也出现问题如下:

enter image description here

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"
}
}

最佳答案

此问题与 react-hot-loader 相关包裹。您正在使用依赖于 ReactMount.js 的旧版本文件存在于node_modules/react/lib中文件夹。

没有简单的一种方法可以解决这个问题,但您有几个选择:

  1. 尝试按照此处的说明进行操作:https://github.com/gaearon/react-hot-loader/blob/v3.0.0-beta.6/docs/README.md#usage-with-external-react (但到目前为止我一直不走运)

  2. 删除 React 的热重载程序(在您的 webpack.config 中删除 'react-hot' 加载程序)

  3. 更新react-hot-loader打包到版本 3(操作方法如下: https://github.com/gaearon/redux-devtools/commit/64f58b7010a1b2a71ad16716eb37ac1031f93915 )。但请注意,该软件包已经处于 alpha 状态一段时间了...

  4. 将您的 React 版本回滚到包含 ReactMount.js 的版本在lib文件夹中(15.0.1曾经有这个文件不确定什么时候停止的)。

更新:React Hot Loader 3 现已进入测试阶段,并提供更全面的升级指南:https://github.com/gaearon/react-hot-loader/tree/v3.0.0-beta.7/docs#migration-to-30

关于reactjs - "module not found : Error: Cannot resolve module ' react /lib/ReactMount ' ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40652327/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com