gpt4 book ai didi

node.js - 找不到 `pages` 目录。下一个js

转载 作者:太空宇宙 更新时间:2023-11-04 03:18:33 27 4
gpt4 key购买 nike

我按照指示做一切https://nextjs.org/learn/basics/getting-started/setup

我运行npm run dev

并显示错误

Div-Man@DivMan MINGW64 /f/nextjs/hello-next
$ npm run dev

> hello-next@1.0.0 dev F:\nextjs\hello-next
> next

> Couldn't find a `pages` directory. Please create one under the project root
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-next@1.0.0 dev: `next`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-next@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Div-Man\AppData\Roaming\npm-cache\_logs\2018-11-08T07_58_57_773Z-debug.log
<小时/>
 $ node -v
v10.6.0

$ npm -v
6.1.0

Windows 8.1

package.json

{
"name": "hello-next",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "next",
"build": "next build",
"start": "next start"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"next": "^7.0.2",
"react": "^16.6.1",
"react-dom": "^16.6.1"
}
}
<小时/>
   npm start

> hello-next@1.0.0 start F:\nextjs\hello-next
> next start

Error: Could not find a valid build in the 'F:\nextjs\hello-next\.next' director y! Try building your app with 'next build' before starting the server.
at Server.readBuildId (F:\nextjs\hello-next\node_modules\next\dist\server\ne xt-server.js:753:15)
at new Server (F:\nextjs\hello-next\node_modules\next\dist\server\next-serve r.js:80:25)
at module.exports (F:\nextjs\hello-next\node_modules\next\dist\server\next.j s:6:10)
at _callee$ (F:\nextjs\hello-next\node_modules\next\dist\server\lib\start-se rver.js:33:37)
at tryCatch (F:\nextjs\hello-next\node_modules\regenerator-runtime\runtime.j s:62:40)
at Generator.invoke [as _invoke] (F:\nextjs\hello-next\node_modules\regenera tor-runtime\runtime.js:288:22)
at Generator.prototype.(anonymous function) [as next] (F:\nextjs\hello-next\ node_modules\regenerator-runtime\runtime.js:114:21)
at asyncGeneratorStep (F:\nextjs\hello-next\node_modules\@babel\runtime-core js2\helpers\asyncToGenerator.js:5:24)
at _next (F:\nextjs\hello-next\node_modules\@babel\runtime-corejs2\helpers\a syncToGenerator.js:27:9)
at F:\nextjs\hello-next\node_modules\@babel\runtime-corejs2\helpers\asyncToG enerator.js:34:7
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-next@1.0.0 start: `next start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-next@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional log ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Div-Man\AppData\Roaming\npm-cache\_logs\2018-11-08T08_25_2 3_194Z-debug.log

最佳答案

nextJS需要到“pages”目录。

制作“页面”,然后在里面制作index.js。 (例如pages/index.js)

关于node.js - 找不到 `pages` 目录。下一个js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53203694/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com