如何更改 Remix.run 本地开发服务器使用的端口?

Dar*_*ody 14 javascript remix.run

默认情况下,Remix.run 运行时似乎使用端口 3000 进行本地开发:

\n
\xe2\x9d\xaf npm run dev\n\n> dev\n> concurrently "npm run dev:css" "remix dev"\n\n[0]\n[0] > dev:css\n[0] > tailwindcss -o ./app/styles/tailwind.css --watch\n[0]\n[1] Watching Remix app in development mode...\n[1]  Built in 161ms\n[1] Remix App Server started at http://localhost:3000\n\n
Run Code Online (Sandbox Code Playgroud)\n

如何更改它运行的端口?

\n

Dar*_*ody 23

从 v1.1.3(~2022 年 1 月)开始,本地开发端口配置了环境PORT变量。

例子:

PORT=10000 npm run dev
Run Code Online (Sandbox Code Playgroud)

给予

> dev
> concurrently "npm run dev:css" "remix dev"

[0]
[0] > dev:css
[0] > tailwindcss -o ./app/styles/tailwind.css --watch
[0]
[1] Watching Remix app in development mode...
[1]  Built in 162ms
[1] Remix App Server started at http://localhost:10000
Run Code Online (Sandbox Code Playgroud)

  • 对于初学者,您可以修改package.json文件中的scripts并添加此端口。例如,将 `"dev": "remix dev"` 更改为 `"dev": "PORT=10000 remix dev"` (2认同)