![](/img/trans.png)
[英]Migration to React 16.0.0 Error: Cannot find module “react/lib/ReactComponentTreeHook”
[英]cannot find module “react/lib/ReactComponentTreeHook” error when updating to React 16.2.0
在我的程序包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導入的,但是如果這是最新版本的匹配react,我不明白為什么會有這個問題。
在我能想到的選項之外,將不勝感激。 謝謝。
嘗試清除我的node_modules,重新安裝所有內容
請記住,從NPM 5版開始,它會生成程序包鎖定文件,而不會清除重新安裝模塊將無法正常工作的情況。
還要檢查以下-如果一些包已經擁有依賴於舊react
包的版本,它將被安裝到嵌套node_modules
目錄,然后一切都依賴於項目/裝載機結構。 在這種情況下,將加載無效的新或舊軟件包版本。 在某些npm軟件包中,例如graphql
,針對該情況添加了特殊警告:“也許您安裝了不同版本的軟件包”。
因此,請檢查其他軟件包的版本,並可能對其進行更新。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.