簡體   English   中英

嘗試在之后立即啟動 React 時出錯(項目依賴樹可能有問題......)

[英]Getting an error trying to start React right after (There might be a problem with the project dependency tree…)

我已經從 npx create-react-app 創建了 React App。 而且,我嘗試 cd 並啟動該應用程序並顯示此錯誤。 我也嘗試過使用紗線並重新安裝節點。 我非常迷茫,因為它也像 30 分鍾前一樣在 wooooorking。 我唯一做的是 npm i -g npm 來更新 npm ,從那以后它就不起作用了。

We suggest that you begin by typing:

  cd giact
  yarn start

Happy hacking!
gi@Gis-Macbook-Pro study % cd giact
gi@Gis-Macbook-Pro giact % npm start

> giact@0.1.0 start /Users/gi/Desktop/Study/giact
> 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:

  "babel-eslint": "10.1.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-eslint was detected higher up in the tree:

  /Users/gi/node_modules/babel-eslint (version: 9.0.0) 

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would 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 "babel-eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
  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 versions.

  6. Check if /Users/gi/node_modules/babel-eslint is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls babel-eslint in your project folder.
     This will tell you which other package (apart from the expected react-scripts) installed babel-eslint.

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!

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! giact@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the giact@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/gi/.npm/_logs/2020-04-19T18_13_36_022Z-debug.log

/Users/gi go 輸入 npm i babel-eslint@10.1.0 它會解決你的問題。 它對我有用

1) Create React App 提供的 react-scripts package 需要依賴:

“babel-eslint”:“10.1.0”,“eslint”:“^6.8.0”

使用命令: npm install eslint@6.x babel-eslint@10 --save-dev

通過刪除我的“ C:\Users ”文件夾中的node_modules解決了我的問題。

我按照它為我工作的一些步驟。

第 1 步:更改您的項目位置,就好像您將其保存在D drive上一樣將其更改為E drive

步驟 2:刪除節點模塊。

第 3 步:運行此命令安裝節點模塊 >> npm install

快速修復是在項目文件夾中創建一個名為 .env 的文件,其內容如下SKIP_PREFLIGHT_CHECK=true

I couldn't get anything else to work, npm, yarn, deleting lock, deleting node_modules, etc. This is just happening in my linux mint environment, not on windows or ubuntu.

對我有用的是在我的 Mac 上搜索 node_modules 的所有實例,刪除所有實例,轉到要托管這些文件的目錄,然后在該目錄的終端中重新運行以下命令:

--> npm install -g create-react-app
--> create-react-app jsx 

(更改到您的 React 目錄(即您的 React 項目的名稱,在我的例子中是 'jsx'))

--> npm start

當我在另一個反應項目中創建一個反應項目時,我遇到了這種錯誤。 如果您在另一個反應項目中有反應項目,這種錯誤將很常見。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM