簡體   English   中英

無法在 Linux 的 Windows 子系統上運行反應服務器(ubuntu)

[英]cant run react server on Windows Subsystem for Linux (ubuntu)

所以我試圖在 ubuntu 上使用 reactjs 開發服務器從 Windows ZEDC9F0A5A373648 子系統運行

當我跑步時

sudo npm start

我收到這樣的錯誤:

啟動開發服務器...

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

Error: spawn cmd.exe ENOENT
    at _errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
    at onErrorNT (internal/child_process.js:372:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! counter-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the counter-app@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:
the log file

這是日志文件:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@6.12.1
3 info using node@v8.10.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle counter-app@0.1.0~prestart: counter-app@0.1.0
6 info lifecycle counter-app@0.1.0~start: counter-app@0.1.0
7 verbose lifecycle counter-app@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle counter-app@0.1.0~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/mnt/d/project/excercises/node/react$9 verbose lifecycle counter-app@0.1.0~start: CWD: /mnt/d/project/excercises/node/react/counter-app
10 silly lifecycle counter-app@0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle counter-app@0.1.0~start: Returned: code: 1  signal: null
12 info lifecycle counter-app@0.1.0~start: Failed to exec start script
13 verbose stack Error: counter-app@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid counter-app@0.1.0
15 verbose cwd /mnt/d/project/excercises/node/react/counter-app
16 verbose Linux 4.4.0-18362-Microsoft                                                                                                                          17 verbose argv "/usr/bin/node" "/usr/local/bin/npm" "start"                                                                                                    18 verbose node v8.10.0                                                                                                                                         19 verbose npm  v6.12.1
20 error code ELIFECYCLE
21 error errno 1
22 error counter-app@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the counter-app@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

我試過了:

sudo npm cache clear --force
sudo rm -rf node_modules
sudo npm install
sudo npm start

但我仍然收到錯誤

我也試過:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

但它也不能解決任何問題

沒關系,我試圖在根文件夾上安裝 npm,我應該在文件夾 app 上安裝 npm

所以我遇到了一個新問題,我正在嘗試在 Port=80 上運行 reactjs

但我不能使用:

sudo PORT=80 npm start

它返回上面的錯誤

奇怪的是,如果我只使用它就可以完美運行

npm start

暫無
暫無

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

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