iT邦幫忙

0

#發問 npm start無法啟動

PS C:\Users\user\Desktop> npx create-react-app test
Starting the development server...

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

Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@0.1.0 start: react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test@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\user\AppData\Roaming\npm-cache\_logs\2020-04-16T05_36_38_598Z-debug.log
PS C:\Users\user\Desktop\test>

我上網查了很久,使用過幾個方法

  1. 刪除node_modules和package-lock.json
    重新npm install,npm start
  2. 環境變數 路徑都有設 也重設
  3. 更換不同node版本試試看

可是結果npm start都是跑出以上錯誤
本來可以正常使用
用mac也可以開
是不是我忽略了windows的什麽問題QQ

謝謝大家~

看更多先前的討論...收起先前的討論...
要修改環境變數內的path,
要在裡面加入 %SystemRoot%\system32;
這個有設過嗎
不要在桌面(Desktop)或個人盒做這檔事。
很容易被權限問題給檔下來的。
光看到「C:\Users\user\Desktop」這個路徑。
我就不想找原因了。
對~我就是設這個
@浩瀚星空 好 那請問一般你創建React項目的路徑會是~?
至少一定不會在c:。
我個人是偏向使用linux做開發。
就算是本地。也會開linux機器做為我的主要開發機。

當然,我也不會要求你跟我一樣這樣做。
但如果有非c的位置。就盡量往別的地方。

windows系統對於主系統碟,很常會做一些限制。
再加上有物件指向式的碟位。你會很容易踩到雷。
如果真的只剩下c。我也會另開一個目錄來處理。也不會直接在其對應的C:\Users\user大多數是個人用資料。這邊已被windows設了很多規則。
能不放這就不放這。
咖咖拉 iT邦好手 1 級 ‧ 2020-04-16 15:02:47 檢舉
windows 的環境是最高管理員嗎?
電腦有設網域?
你要不要試試 cmd 而不是 powershell
謝謝你~~
因為我剛接觸 平常都用mac開發
不知道windows有這些限制
google了一下,發現這個,看起來有點像:
https://github.com/facebook/create-react-app/issues/6908
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
咖咖拉
iT邦好手 1 級 ‧ 2020-04-16 15:09:07

可能是全域的問題 要測看看才知道
先cd 專案中的node_modules>.bin

cd node_modules\.bin

再打
npm start
看看能不能開啟

我要發表回答

立即登入回答