在开发模式下运行良好时,在构建NextJS应用程序的构建时获取404页
我对反应/下一个JS是很新的。所以这是我的问题。我已经购买了一个主题,并更改了配置和品牌部分。现在,当我使用“ Yarn Dev”和“ Yarn Start”运行该应用程序时,它正常工作。 “纱线构建”还创建了优化的生产构建。我想在我的PC上本地部署该应用程序,并且试图通过YouTube视频来学习内容。因此,在其中一个视频中,我找到了此命令(“ prod”:“下一个构建&& serve build build”),以包含在package.json中。我的poffage.json文件具有以下脚本。
“脚本”:{ “ dev”:“ Next Dev”, “构建”:“下一个构建”, “开始”:“下一个开始”, “导出”:“ Next Export”, “ lint”:“ eslint -fix” src//*。{js,jsx}“”, “格式”:“ Prettier -write” Src//*。{JS,JSX}“”, “ prod”:“下一个构建&& serve build'' },
因此,当我尝试使用“纱线产品”时,它首先创建了优化的构建,然后在VSCODE终端中获得以下输出
但是,如果我尝试打开“ http:// localhost) :3000英寸在我的浏览器中。我有404错误。但不是使用“纱线开发”或“纱线开始”。构建应用程序时也没有错误。
I am pretty new to React/Next JS. So here's my issue. I have purchased a theme and made changes to the config and branding part. Now when I run the app using "yarn dev" and "yarn start", it is working fine. "yarn build" also creates an optimized production build. I wanted to deploy the app locally in my PC and i was trying to learn things through youtube videos. so in one of the videos i found this command ("prod": "next build && serve build") to include in package.json. my package.json file has the following scripts.
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"export": "next export",
"lint": "eslint --fix "src//*.{js,jsx}"",
"format": "prettier --write "src//*.{js,jsx}"",
"prod": "next build && serve build"
},
so when i try with "yarn prod", it is first creating an optimized build and then i get the following output in the vscode terminal
however if i try to open "http://localhost:3000" in my browser. i get 404 error. but not with "yarn dev" or "yarn start". no error while building the app too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加“ cleanurls”:true 到“ firebase.json”文件,如下
Add the "cleanUrls": true to "firebase.json" file as below