最近:
$ react-scripts start There might be a problem with the project dependency tree. It is likely not a bug in Create React App, but something you need to fix locally. The react-scripts package provided by Create React App requires a dependency: "webpack": "4.19.1" Don't try to install it manually: your package manager does it automatically. However, a different version of webpack was detected higher up in the tree: E:\company_work\wbwork\zabbix2\node_modules\webpack (version: 3.10.0) Manually installing incompatible versions is known to cause hard-to-debug issues. If prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That will permanently disable this message but you might encounter other issues. To fix the dependency tree, try following the steps below in the exact order: 1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder. 2. Delete node_modules in your project folder. 3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project fo lder. 4. Run npm install or yarn, depending on the package manager you use. In most cases, this should be enough to fix the problem. If this has not helped, there are a few other things you can try: 5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead. This may help because npm has known issues with package hoisting which may get resolved in future ver sions. 6. Check if E:\company_work\wbwork\zabbix2\node_modules\webpack is outside your project directory. For example, you might have accidentally installed something in your home folder. 7. Try running npm ls webpack in your project folder. This will tell you which other package (apart from the expected react-scripts) installed webpack. If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That would permanently disable this preflight check in case you want to proceed anyway. P.S. We know this message is long but please read the steps above :-) We hope you find them helpful! error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
一、報錯截圖
二、分析報錯內容
圖1中的報錯信息,主要說的是如下:
這不是create React App時的錯誤,而是需要在本地修復的問題。
由create React App提供的React 腳本包需要安裝依賴項。
"babel-eslint": "9.0.0"
不要嘗試手動安裝:包管理器會自動安裝。
然而,在樹的高處發現了不同版本的Babel Eslint。
已知手動安裝不兼容的版本會導致難以調試的問題。
如果希望忽略此檢查,請將skip_preflight_check=true添加到項目中的.env文件中。
這將永久禁用此郵件,但您可能會遇到其他問題。
若要修復依賴關系樹,請嘗試按正確的順序執行以下步驟:
【1】刪除項目中的package-lock.json(不是package.json!)和/或 yarn.lock 文件。
【2】 刪除項目文件夾中的node_modules。
【3】從項目文件夾中package.json文件的devdependencies中刪除“babel eslint”
【4】運行npm install 或 yarn,取決於您使用的包管理器。在大多數情況下,這應該足以解決問題。
如果這沒有幫助,您可以嘗試其他一些方法:
【5】如果使用了NPM,請安裝yarn(http://yarnpkg.com/)並用它重復上述步驟。這可能會有所幫助,因為NPM已經知道包提升的問題,在將來的版本中可能會得到解決
【6】檢查/users/hmly/desktop/react/xiang shou jiu da ka/node_modules/babel eslint是否在項目目錄之外。
例如,您可能意外地在主文件夾中安裝了某些內容。
【7】嘗試在項目文件夾中運行npm ls babel eslint。這將告訴您安裝了babele eslint的其他包(除了預期的react腳本)
如果沒有其他幫助,請將skip_preflight_check=true添加到項目中的.env文件中。
這將永久性地禁用這個飛行前檢查,以防您仍然想繼續
三、錯誤處理
按照2中的前4步處理,發現仍然不能解決該問題。然后嘗試了【7】的方式,發現確實有兩個版本的babel-eslint ,想起之前確實手動安裝過babel-eslint ,應該是這個問題。
再次進行處理:
1、 刪除項目中的package-lock.json文件(不是package.json)。
2、 刪除項目中的node_modules文件夾。
3、 修改package.json ,把"devDependencies"配置清空,關鍵。


4、 重新運行 npm install 。
5、運行 npm start 成功 ,(后期可根據需要重新配置devDependencies)。