簡體   English   中英

無法識別“npm”中的 create-react-app 結果

[英]create-react-app results in "npm" is not recognized

我從事 React 工作將近 1 年。 我沒有遇到這個問題,但是因為我重新安裝了我的操作系統,我不能使用像這樣的命令:' npx create-react-app my-app ' 並且它得到了這個結果:

'"node"' is not recognized as an internal or external command,
operable program or batch file.

我有

  • 安裝了 nodejs 並將其添加到環境變量的路徑。
  • 重新啟動 VSCode。
  • 重新啟動系統。
  • 卸載了所有內容,包括 Roaming 目錄中的文件。
  • 更改了 nodejs 的安裝目錄並更新了它的路徑
  • 清除節點緩存

但沒有任何效果。

當我輸入“node -v”或“npm -v”時,我會取回版本。 所以他們在系統中被識別。 而且當我使用紗線時,也會發生這種情況:

yarn create react-app client

yarn create v1.22.5
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

success Installed "create-react-app@4.0.3" with binaries:
      - create-react-app

Creating a new React app in D:\Projects\DEVCONNECTOR\client.

'npm' 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...

'npm' is not recognized as an internal or external command,
operable program or batch file.

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts@0.9.x has failed.

Deleting generated file... package.json
Deleting client/ from D:\Projects\DEVCONNECTOR
Done.
error Command failed.
Exit code: 1
Command: C:\Users\damon\AppData\Local\Yarn\bin\create-react-app
Arguments: client
Directory: D:\Projects\DEVCONNECTOR
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

所以它首先開始安裝 package 但隨后出現相同的錯誤並且 package 被刪除。 盡管我可以在啟動服務器等其他命令中使用 yarn。

提前致謝

嘗試刪除節點模塊package-lock.json並運行命令yarn create-react-app client

如果它不起作用嘗試yarn create-react-app client --legacy-peer-deps

暫無
暫無

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

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