Coder Social home page Coder Social logo

Comments (7)

kasajian avatar kasajian commented on August 21, 2024 9

I think this is really awesome that you were able to resolve the problem so quickly, but I'm sorry this is kinda too little too late. The "latest" is whatever is on the site. I went to the site and clicked on the "latest" button that said tutorial. I ran through the latest instructions and I got this defect. So as far as I am concerned, i wasn't not running an older version. I followed the latest instructions.

Hopefully this can be corrected for the next person who is looking at NextJs as a static-site generation tool. It's a good tool, so I hope it works out for them.

I'll be using something else, but will come back to NextJs when i want something more sophisticated, such as a starter-app for React

from staticgen.

timneutkens avatar timneutkens commented on August 21, 2024 1

As you can see the default behaviour works as expected with the latest version of Next.js:

yarn create next-app --example basic-export basic-export-app

yarn create v1.7.0
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Installed "[email protected]" with binaries:
      - create-next-app
> Success! Downloaded basic-export files for basic-export-app

  Installing npm modules:
    react
    react-dom
    next

> Success! Installed dependencies for basic-export-app

  Awesome! You're now ready to start coding.

  We already ran yarn for you, so your next steps are:

  $ cd basic-export-app

  To build a version for production:

  $ yarn build

  To run the server in production:

  $ yarn start

  To start a local server for development:

  $ yarn dev

  Questions? Feedback? Please let us know!

  https://github.com/segmentio/create-next-app/issues

✨  Done in 40.95s.

▲  sandbox cd basic-export-app
▲  basic-export-app yarn build
yarn run v1.7.0
$ next build
✨  Done in 4.70s.
▲  basic-export-app yarn export
yarn run v1.7.0
$ next export
> using build directory: /Users/timneutkens/projects/sandbox/basic-export-app/.next
  copying "static build" directory
> No "exportPathMap" found in "next.config.js". Generating map from "./pages"
> exporting path: /about
> exporting path: /about2
> exporting path: /day
> exporting path: /index
> exporting path: /_error
> exporting path: /

✨  Done in 0.61s.

from staticgen.

timneutkens avatar timneutkens commented on August 21, 2024

Could not find "exportPathMap" function inside "next.config.js"
Looking through the documentation, it looks like you need to do more coding to get all that to work. It seems like static-site generation is an afterthought for nextjs and very poortly implemented, if anyone even gets it to work.

As per vercel/next.js#1972 this hasn't been a requirement anymore since Next.js 6+.

I suspect that's not the main Use Case anyway. Going through the tutorial and the overview, it hardly mentions that Use Case. It's deeper in the docs, and I honestly would have missed it entirely if it hadn't been for the fact that the StaticGen site pointed me to it.

Next.js implements the process of pre-rendering. In case of next export you pre-render to static HTML. If using next start pages are rendered on-demand. It's definitely one of the main use cases of Next.js.

from staticgen.

kasajian avatar kasajian commented on August 21, 2024

Here's how to reproduce it:

git clone https://github.com/arunoda/learnnextjs-demo.git
cd learnnextjs-demo
git checkout getting-started
npm install
npm run dev
    (shutdown the server)
node_modules\.bin\next build 
node_modules\.bin\next export

My package.json:

{
  "name": "hello-next",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "next"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "next": "^4.2.0",
    "react": "^16.2.0",
    "react-dom": "^16.2.0"
  }
}

from staticgen.

timneutkens avatar timneutkens commented on August 21, 2024
"next": "^4.2.0",

As per what I said earlier:

As per vercel/next.js#1972 this hasn't been a requirement anymore since Next.js 6+.

So the example should just be upgraded to the latest version.

from staticgen.

millette avatar millette commented on August 21, 2024

@kasajian I use nextjs to build static websites and it works quite well. A couple of examples:

Clone either of those, then

npm install
npm run build
npm run export
cd out # and here it is

from staticgen.

timneutkens avatar timneutkens commented on August 21, 2024

I'm creating a PR to fix the Next.js version 👌

from staticgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.