簡體   English   中英

嘗試創建React應用時出現紗線錯誤

[英]Yarn errors when trying to create a React app

我嘗試使用以下命令創建一個React應用程序:

create-react-app eth-todo-list-react

這將產生以下錯誤:

'yarnpkg' is not recognized as an internal or external command,
operable program or batch file.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

'yarnpkg' is not recognized as an internal or external command,
operable program or batch file.
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: spawn yarnpkg ENOENT
    at notFoundError (C:\Users\Aristophanes\node_modules\create-react-app\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\Aristophanes\node_modules\create-react-app\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\Users\Aristophanes\node_modules\create-react-app\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
Emitted 'error' event at:
    at ChildProcess.cp.emit (C:\Users\Aristophanes\node_modules\create-react-app\node_modules\cross-spawn\lib\enoent.js:30:37)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)

它應該說“成功”並初始化git倉庫。 但是我得到了上面的錯誤。 我嘗試了各種方法的故障排除,包括更改路徑和全局安裝yarn,但是當我這樣做之后,再次嘗試創建react app時,出現此錯誤:

The directory eth-todo-list-react contains files that could conflict:

  package.json
  yarn.lock

Either try using a new directory name, or remove the files listed above.

如果我刪除此文件並嘗試再次創建react應用,則會再次遇到第一個錯誤。

嘗試使用npx命令,

npx create-react-app my-project

如果您使用npx ,則不需要像create-react-app這樣的全局安裝軟件包。

全部告訴node -vnpm -v

通過在控制台中鍵入create-react-app --version來獲取您的create-react-app的create-react-app --version 這使用2.1.5版為我成功構建。 您可能需要更新您的create-react-app。 npm uninstall -g create-react-app npm create-react-app eth-todo-list-react應該使用最新版本的create-react-app。

暫無
暫無

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

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