簡體   English   中英

npm 啟動問題(錯誤:spawn cmd ENOENT)

[英]Problem with npm start (error : spawn cmd ENOENT)

我的申請有問題。 因為之前當我創建一個應用程序時它工作,但現在,它向我顯示了這個錯誤,我不知道為什么以及我必須做的事情來修復它。

你有什么想法可以幫助我嗎? (這是一個 reactJS 應用程序)。

我檢查了一些 stackoverflow 主題,但在我檢查的所有地方,這並不是一個真正有效的答案。

events.js:180
      throw er; // Unhandled 'error' event
      ^

Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:77:11)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:77:11) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn cmd',
  path: 'cmd',
  spawnargs: [ '/c', 'start', '""', '/b', 'http://localhost:3000/' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fix-react-module@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fix-react-module@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!     C:\Users\Lucas\AppData\Roaming\npm-cache\_logs\2019-07-16T09_33_39_111Z-debug.log

C:\\Windows\\System32添加到全局 PATH 環境變量中。

解決方案1

將您的環境變量設置為 C:\\Windows\\System32 。 這對我有用。

設置系統變量

解決方案2


如果第一個不起作用,請按照第二個步驟操作。 導航到您的項目文件夾並鍵入此命令 >>>

rm -rf node_modules

rm package-lock.json

rm  yarn.lock

npm cache clear --force

npm install

解決方案3

降級 package.json 文件中的 react-scripts

嘗試安裝 Mongo DB 后,我遇到了同樣的問題。 我發現這個問題只存在於 react-scripts@3.0.0。 嘗試使用不同的 React 腳本版本重新安裝 npm。 只需在命令中轉到您的文件夾並像這樣重新安裝:

npm install react-scripts@2.1.8
npm start

之后,該應用程序再次為我工作。

對於所有因反應腳本未啟動而遇到此問題的人。 解決辦法是

  1. 轉到搜索欄並編寫環境變量 您應該會看到一個選項來調用編輯系統環境變量或類似的東西。
  2. 在高級部分下有一個環境變量按鈕。 點擊它。
  3. 之后,您將看到一個名為path單擊它的選項。
  4. 單擊添加按鈕並添加以下目錄C:\\Windows\\System32
  5. 關閉編輯器並重新啟動命令終端。 問題現在應該解決了😁

如果有人在 Angular 2+ 中遇到這個問題,請從 ng serve 中刪除 --open 或在沒有此選項的情況下運行。

運行以下命令

npx create-next-app@latest

暫無
暫無

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

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