在我的软件包JSON中将react和react-dom更改为16.2.0并收到以下错误。
Uncaught Error: Cannot find module "react/lib/ReactComponentTreeHook"
尝试清除我的node_modules,重新安装所有内容,从一个新项目开始,在小块中添加依赖项以缩小问题范围,并尝试在堆栈溢出时已经看到的每个选项。
我的package.json如下:
{
"name": "",
"version": "0.0.1",
"description": "",
"main": "index.js",
"repository": {
"type": "git",
"url": "..."
},
"scripts": {
"dev": "webpack -d --watch",
"build": "webpack -p"
},
"dependencies": {
"axios": "^0.17.1",
"body-parser": "^1.18.2",
"classnames": "^2.2.5",
"connect-mongo": "^2.0.0",
"cookie-parser": "^1.4.3",
"express": "^4.16.2",
"express-session": "^1.15.6",
"moment": "^2.19.3",
"mongoose": "^4.13.6",
"multer": "^1.3.0",
"node-sass": "^4.7.2",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"qs": "^6.5.1",
"react": "^16.2.0",
"react-click-outside": "^3.0.0",
"react-dom": "16.2.0",
"react-redux": "5.0.6",
"redux": "3.7.2",
"redux-logger": "^3.0.6",
"redux-promise-middleware": "^5.0.0",
"redux-thunk": "^2.2.0",
"underscore": "^1.8.3"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.7",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.5",
"redux-devtools": "^3.4.1",
"sass-loader": "^6.0.6",
"serve": "^6.4.1",
"style-loader": "^0.19.0",
"svg-sprite-webpack-plugin": "^1.1.0",
"svg-spritemap-webpack-plugin": "^1.0.3",
"url-loader": "^0.6.2",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"webpack": "^3.10.0"
},
"author": "",
"license": "ISC",
"homepage": ""
}
在错误输出的行放置一个断点后,似乎堆栈跟踪来自react-dom的导入,但如果是最新版本匹配反应,我不明白为什么我有这个问题。
出于我能想到的选项,我们将不胜感激。感谢。
答案 0 :(得分:1)
尝试清除node_modules,重新安装所有内容
请记住,从NPM第5版开始,它会生成包锁文件,而不会清除重新安装模块将无法正常工作。
同时检查以下内容 - 如果某个软件包对旧的react
软件包版本有自己的依赖关系,它将被安装到嵌套的node_modules
目录中,然后一切都依赖于项目/加载器结构。在这种情况下,将加载无效的新旧包版本。在某些npm软件包中,例如graphql
,为该案例添加了特殊警告:"也许您已经安装了不同版本的软件包"。
所以,检查其他包裹'版本,也许更新它们。