“找不到模块:错误:无法解析模块'react / lib / ReactMount'”

艾尔莎:

我使用Reactjs和webpack来启动一个项目,当我在命令提示符下运行“节点服务器”时,出现了如下错误:

在此处输入图片说明

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

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

对此没有一种简单的解决方法,但是您可以选择以下几种方法:

  1. Try to follow the instructions here: https://github.com/gaearon/react-hot-loader/blob/v3.0.0-beta.6/docs/README.md#usage-with-external-react (but I have been unlucky so far)

  2. Remove the hot reloader for react (in your webpack.config remove the 'react-hot' loader)

  3. Update the react-hot-loader package to version 3 (here is how to do so: https://github.com/gaearon/redux-devtools/commit/64f58b7010a1b2a71ad16716eb37ac1031f93915). But note that this package has been in alpha for a while now...

  4. Rollback your react version to one that includes the ReactMount.js in the lib folder (15.0.1 used to have this file not sure when it stopped).

更新: React Hot Loader 3现在处于beta中,并提供了更全面的升级指南:https : //github.com/gaearon/react-hot-loader/tree/v3.0.0-beta.7/docs#migration-to-30

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

更新后出现错误:无法解析模块'react / lib / ReactMount'

React 16升级..错误:无法解析'react / lib / ReactMount'

找不到模块:无法解析'react / lib / React'

React js - 无法使用反应图标,找不到模块“../lib”

找不到模块:错误:无法解析“ ./lib/axios”

找不到模块:无法解析“ \ node_modules \ react-addons-perf”中的“ react-dom / lib / ReactPerf”

无法解析模块react / lib / ReactUpdates

找不到模块:错误:无法解析“ cypress-react-selector”

迁移到React 16.0.0错误:找不到模块“ react / lib / ReactComponentTreeHook”

开玩笑失败并显示错误:找不到模块'react / lib / ReactComponentTreeHook'

从'ReactDebugTool.js'中找不到模块'react / lib / ReactComponentTreeHook'

找不到模块:错误:无法解析模块“ react-addons-test-utils”

ModuleNotFoundError:找不到模块:错误:无法解析“ node_modules / mongodb / lib”中的“ dns”

Webpack - 找不到模块:错误:无法解析“node_modules\chokidar\lib”

无法解析模块“ react-redux / lib / components / connect”

未找到 React-icons 模块:无法解析“../lib”

错误:找不到模块“ ../lib/cli”

找不到模块:错误:无法解析'./components/PropTest1'-React JS

找不到模块:错误:无法解析“ ../aws-exports”(React-Native Expo Web)

错误:无法从index.js中解析模块react:在项目中找不到反应

[React Webpack]:找不到模块:错误:无法解析“ C:\ Users \ ....”中的“ src / views / UserList”

React NextJS应用程序,安装了webpack,然后将其删除:错误:找不到模块“ webpack / lib / node / NodeOutputFileSystem”

找不到./node_modules/@elastic/elasticsearch/lib/Connection.js模块中的错误:错误:无法解析“ http”

反应:找不到模块:无法解析“ react-html-parser”

找不到模块:无法解析“react-redux-form”

找不到模块:无法解析“ react-router-dom”

找不到模块:无法解析“@react-three/cannon”

找不到模块:错误:无法解析“ C:\ dev \ jszip-test \ node_modules \ jszip \ lib”中的“流”

模块构建失败(来自./node_modules/babel-loader/lib/index.js):错误:找不到模块“ babel-preset-react”