run without any error
work good with node server.js
but with: next export got error Couldn't find apagesdirectory. Please create one under the project root
./srcserver.jsconst app = next({ dev, dir: './src' });"export": "next export"| Tech | Version |
|---------|---------|
| next | 4.2.1 |
| node | v7.6.0 |
| OS | window 8.1 |
| browser | chrome |
@krasevych I got this to work as follows:
Add to src/next.config.js:
module.exports = {
exportPathMap() {
return {
'/': { page: '/' },
'/about': { page: '/about' },
}
},
Add 'src' directory to package.json scripts:
"scripts": {
"dev": "next src",
"build": "next build src",
"start": "next start src",
"export": "next build src && next export src",
yarn export produces a static build in src/out
dir is a next.js app root. So you need to have pages in src/pages.
@timneutkens but I wrote move pages to ./src, that means I have page in ./src/pages
Ah, sorry @krasevych I understood it as: moved pages to src as in mv -r pages/* src, which wouldn't work 馃槈 i'll check your issue out after v5 is released 馃憤
Actually you're confusing 2 things. next export doesn't use the custom server. @gihrig's explanation is correct. You need to provide the dir to next build and next export. Then it'll work 馃憤
@gihrig @timneutkens thanks!
Most helpful comment
@krasevych I got this to work as follows:
Add to
src/next.config.js:Add 'src' directory to
package.jsonscripts:yarn exportproduces a static build insrc/out