根据 NextJs 文档启动空项目时开发服务器从不响应
The dev server never responds when starting an empty project based on NextJs documentation
基于 NextJs framework documentation,我遵循了一些设置步骤 运行 一个空项目:
mkdir hello-next
cd hello-next
npm init -y
npm install --save react react-dom next
mkdir pages
然后我将这 3 行添加到我的 package.json
文件中:
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
}
所以现在一切都应该准备好制作我的应用程序 运行,执行此命令行:
npm run dev
但我总是在 http://localhost:3000
上陷入 无限加载循环 。
在我的控制台输出上:
[ wait ] starting the development server ...
[ info ] waiting on http://localhost:3000 ...
[ ready ] compiled successfully (ready on http://localhost:3000)
你是对的,它并不像教程建议的那样工作。我在 Next Github 存储库 中打开了 an issue,现在已解决,应该在 9.0.1 版本中提供修复。
同时,您可以通过在pages
目录中创建一个名为index.js
或index.jsx
的文件并重新启动服务器来添加一个简单的页面。
// pages/index.js
export default () => 'Super simple page';
然后,导航到 http://localhost:3000
应该显示此页面,任何其他路径应该显示默认的 Next 的 404 错误页面。
基于 NextJs framework documentation,我遵循了一些设置步骤 运行 一个空项目:
mkdir hello-next
cd hello-next
npm init -y
npm install --save react react-dom next
mkdir pages
然后我将这 3 行添加到我的 package.json
文件中:
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
}
所以现在一切都应该准备好制作我的应用程序 运行,执行此命令行:
npm run dev
但我总是在 http://localhost:3000
上陷入 无限加载循环 。
在我的控制台输出上:
[ wait ] starting the development server ...
[ info ] waiting on http://localhost:3000 ...
[ ready ] compiled successfully (ready on http://localhost:3000)
你是对的,它并不像教程建议的那样工作。我在 Next Github 存储库 中打开了 an issue,现在已解决,应该在 9.0.1 版本中提供修复。
同时,您可以通过在pages
目录中创建一个名为index.js
或index.jsx
的文件并重新启动服务器来添加一个简单的页面。
// pages/index.js
export default () => 'Super simple page';
然后,导航到 http://localhost:3000
应该显示此页面,任何其他路径应该显示默认的 Next 的 404 错误页面。