1

我希望能够在离线时在我的 Mac 上查看 MUI 的组件库和 api 文档。MUI 支持人员向我提供了以下说明

这就是我放入终端的内容。

git clone https://github.com/mui-org/material-ui.git
cd material-ui
yarn
yarn docs:build
yarn docs:start

这就是我从 终端中得到的

apple2@apple2s-iMac material-ui % yarn docs:start
yarn run v1.22.10
$ yarn workspace docs start
$ next start
Error: listen EADDRINUSE: address already in use 0.0.0.0:3000
    at Server.setupListenHandle [as _listen2] (node:net:1330:16)
    at listenInCluster (node:net:1378:12)
    at doListen (node:net:1516:7)
    at processTicksAndRejections (node:internal/process/task_queues:84:21) {
  code: 'EADDRINUSE',
  errno: -48,
  syscall: 'listen',
  address: '0.0.0.0',
  port: 3000
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 1
Command: /usr/local/Cellar/node/17.3.0/bin/node
Arguments: /Users/apple2/Desktop/Code/material-ui/.yarn/releases/yarn-1.22.10.js start
Directory: /Users/apple2/Desktop/Code/material-ui/docs
Output:

info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
apple2@apple2s-iMac material-ui % 

我应该为每个命令输入添加终端输出吗?(yarn docs:build 是很多行)

4

1 回答 1

0

错误消息EADDRINUSE告诉您,您已经在端口 3000 上侦听了某些内容。您需要停止当前使用端口 3000 的进程/应用程序,以便您可以运行 MUI 文档 告诉 MUI 文档使用另一个端口。

您可以执行以下操作之一:

  • 告诉 MUI 文档在不同的端口上运行:(yarn docs:start --port=3001这可能是你最好的选择。)

  • 寻找应用程序(可能是另一个终端窗口——你的另一个 React 应用程序?)并停止它(Ctrl+ C

  • 重新启动您的机器并确保没有任何东西开始在端口 3000 上进行侦听。

  • 在终端中找到进程 ID 并手动将其终止。

要在终端中查找进程 ID 并手动终止它,请在 Mac 上打开终端并键入以下命令:

获取侦听端口 3000 的所有进程的列表(sudo将要求您输入密码)

sudo lsof -i :3000

将显示当前侦听端口 3000 的进程列表。例如:

COMMAND   PID           USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
node    53763 [your username]   28u  IPv4 0x6c9dbf461b729ff1      0t0  TCP *:hbci (LISTEN)

在列表中找到要杀死的进程的进程 id (PID)——在上面的示例中,进程 id 是“53763”。

杀死进程:

kill -9 53763

现在尝试重新运行 MUI 文档:

yarn docs:start
于 2022-01-29T10:03:25.170 回答