Next.js - Localhost拒绝连接

3b6akqbq  于 2023-04-30  发布在  其他
关注(0)|答案(1)|浏览(195)

我的问题

我想学习下一个。js,但是当我创建一个空的Next时。js项目,我运行npm run dev时无法连接到本地主机。我正在做以下工作:

  1. npx create-next-app@latest
    1.我给我的项目起了个名字。
  2. cd project-name
  3. npm run dev
    这是我在命令提示符中看到的全部内容,在最后一条信息之后,服务器关闭。我不认为我的下一个。js服务器可以正确启动,因为在我运行npm run dev之后,它跳到了新的一行。
PS C:\Users\Username\Documents\Programmering\next13-experiment> npm run dev
next13-experiment@0.1.0 dev
next dev -p 3000

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
warn  - You have enabled experimental feature (appDir) in next.config.js.
info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

info  - Using wasm build of next-swc

PS C:\Users\Username\Documents\Programmering\next13-experiment> npx create-next-app@latest --experimental-app

我所尝试的

我试图检查是否有任何进程通过netstat -ano | findstr :3000使用端口3000,但没有。我在防火墙入站规则中也找不到。
我试图禁用防火墙或任何防病毒。
我将127.0.0.1 localhost添加到C:\Windows\System32\drivers\etc\hosts并重新启动PC。
我试着更改包中的端口。json。

系统

Windows 10,Node v18。15.0下一个133.0,不使用任何VPN

nwsw7zdq

nwsw7zdq1#

解决方案是卸载Node v18。15.0,安装Node v18。16.0,然后重新启动我的电脑。这样做之后,问题解决了。

相关问题