{"id":13506747,"url":"https://github.com/nuxt-community/nuxt-generate-cluster","last_synced_at":"2025-08-01T16:10:44.274Z","repository":{"id":46223054,"uuid":"107804867","full_name":"nuxt-community/nuxt-generate-cluster","owner":"nuxt-community","description":"Multi-threaded generator command for nuxt.js","archived":false,"fork":false,"pushed_at":"2021-11-05T15:47:56.000Z","size":869,"stargazers_count":153,"open_issues_count":8,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-05T12:48:39.718Z","etag":null,"topics":["cluster","generator","multi-threaded","nuxt"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nuxt-community.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-21T18:20:44.000Z","updated_at":"2024-09-10T05:53:14.000Z","dependencies_parsed_at":"2022-08-31T02:41:49.265Z","dependency_job_id":null,"html_url":"https://github.com/nuxt-community/nuxt-generate-cluster","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/nuxt-community/nuxt-generate-cluster","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-community%2Fnuxt-generate-cluster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-community%2Fnuxt-generate-cluster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-community%2Fnuxt-generate-cluster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-community%2Fnuxt-generate-cluster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nuxt-community","download_url":"https://codeload.github.com/nuxt-community/nuxt-generate-cluster/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-community%2Fnuxt-generate-cluster/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268257356,"owners_count":24221058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cluster","generator","multi-threaded","nuxt"],"created_at":"2024-08-01T01:00:56.639Z","updated_at":"2025-08-01T16:10:44.251Z","avatar_url":"https://github.com/nuxt-community.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized","JavaScript"],"sub_categories":["Uncategorized"],"readme":"# Multi-threaded generate command for Nuxt.js\n\u003ca href=\"https://travis-ci.org/nuxt-community/nuxt-generate-cluster\"\u003e\u003cimg src=\"https://api.travis-ci.org/nuxt-community/nuxt-generate-cluster.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://ci.appveyor.com/project/pimlie/nuxt-generate-cluster\"\u003e\u003cimg src=\"https://ci.appveyor.com/api/projects/status/elyk3f85sn2pr9r3?svg=true\" alt=\"Windows Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/nuxt-community/nuxt-generate-cluster\"\u003e\u003cimg src=\"https://img.shields.io/codecov/c/github/nuxt-community/nuxt-generate-cluster/master.svg\" alt=\"Coverage Status\"\u003e\u003c/a\u003e\n[![npm](https://img.shields.io/npm/dt/nuxt-generate-cluster.svg)](https://www.npmjs.com/package/nuxt-generate-cluster)\n[![npm (scoped with tag)](https://img.shields.io/npm/v/nuxt-generate-cluster/latest.svg)](https://www.npmjs.com/package/nuxt-generate-cluster)\n\u003ca href=\"https://github.com/nuxt/nuxt.js/\"\u003e\u003cimg src=\"https://img.shields.io/badge/nuxt.js-v2.11-800080.svg\" alt=\"\"/\u003e\u003c/a\u003e\n\n\u003e Use multiple workers to generate the static files for your Nuxt.js project\n\n## Setup\n\nInstall the package\n```\nyarn add nuxt-generate-cluster\n```\n\nAdd a generate script to your `package.json`\n```js\n  \"scripts\": {\n    \"generate\": \"nuxt-generate -w 4\"\n  }\n```\n\n## Nuxt config options\n\nConfigure the generate options in `nuxt.config.js`\n```js\n  generate: {\n    workers: 4,\n    workerConcurrency: 500,\n    concurrency: 500,\n    routes (callback, params) {\n      return axios.get('https://api.example.com/routes?since=' + params.lastFinished)\n      .then((res) =\u003e {\n        return res.data\n      })\n    },\n    done ({ duration, errors, workerInfo }) {\n      if (errors.length) {\n        axios.post('https://api.example.com/routes', { generate_errors: errors })\n      }\n    }\n  }\n```\n\n### `workers`\n- Default: number of processors\n\nThe number of workers that should be started. It probably has no use to start more workers then number of processors in your system.\n\n### `workerConcurrency`\n- Default: `500`\n\nTo even the load between workers they are sent batches of routes to generate, otherwise a worker with 'easy' routes might finish long before others. Workers will also still use the concurrency option from Nuxt.\n\n### `routes`\n\nThe default [Nuxt.js routes method](https://nuxtjs.org/api/configuration-generate#routes) has been extended so you can pass additional parameters to it, see params parameter in example config under Setup. By default\nit will list 3 timestamps:\n\n- `lastStarted`\nThe unix timestamp when the nuxt-generate command was last executed, should be just now\n\n- `lastBuilt`\nThe unix timestamp when the nuxt project was last built by nuxt-generate\n\n- `lastFinished`\nThe unix timestamp when nuxt-generate last finished succesfully (eg not interrupted by `ctrl+c`)\n\n\u003e Timestamps are locally stored in `~/.data-store/nuxt-generate-cluster.json`, see [data-store](https://github.com/jonschlinkert/data-store)\n\n### `beforeWorkers`\n\nThis method is called on the master just before the workers are started/forked. It receives the Nuxt options as first argument.\n\nUse this method if you experience serialization issues or when your Nuxt config is too big. The Nuxt options are stringified and then passed as environment variable to the workers, on Windows there seems to be a maximum size of 32KB for env variables.\n\nProperties which should be safe to remove are (not a complete list):\n- buildModules (and their options)\n- serverMiddleware\n\n### `done`\n\nThis method will be called when all workers are finished, it receives two arguments:\n\n- The first argument is an object with statistics:\n  - `duration`\n  The total time in seconds that the command ran\n\n  - `errors`\n  An array of all the errors that were encountered. Errors can have type `handled` or `unhandled`, for the latter the error message will contain the stacktrace\n\n  ```js\n  [ { type: 'handled',\n      route: '/non-existing-link',\n      error:\n       { statusCode: 404,\n         message: 'The message from your 404 page' } }\n  ]\n  ```\n\n  - `workerInfo`\n  An object with detailed information about each worker. Data passed is from the watchdog object that we use internally to monitor the worker status.\n\n  ```js\n  {{ '6707':                            // the process id of the worker\n     { start: [ 1929158, 859524606 ],   // process.hrtime the worker was started\n       duration: 109567,                // how long the worker was active\n       signal: 0,                       // the signal by which the worker was killed (if any)\n       code: 0,                         // the exit status of the worker\n       routes: 73,                      // the number of routes generated by this worker\n       errors: [] },                    // the errors this worker encountered, errors of all workers\n                                        // combined is the error argument above\n  }\n  ```\n\n- The second argument is the Nuxt instance\n\n## Command-line options\n\n\u003e Please note that you need to explicitly indicate with `-b` that you want to (re-)build your project\n\n```\n$ ./node_modules/.bin/nuxt-generate -h\n\n  Multi-threaded generate for nuxt using cluster\n\n  Description\n    Generate a static web application (server-rendered)\n  Usage\n    $ nuxt-generate \u003cdir\u003e\n  Options\n    -b, --build           Whether to (re-)build the nuxt project\n    -c, --config-file     Path to Nuxt.js config file (default: nuxt.config.js)\n    -h, --help            Displays this message\n    -p, --params          Extra parameters which should be passed to routes method\n                            (should be a JSON string or queryString)\n    -q, --quiet           Decrease verbosity (repeat to decrease more)\n    -v, --verbose         Increase verbosity (repeat to increase more)\n    --fail-on-page-error  Immediately exit when a page throws an unhandled error\n    -w, --workers [NUM]   How many workers should be started\n                            (default: # cpus)\n    -wc [NUM],            How many routes should be sent to\n    --worker-concurrency [NUM]    a worker per iteration\n\n```\n\nIf you need to have more control which routes should be generated, use the `-p` option to pass additional parameters to your routes method.\n\n```\n# nuxt.config.js\ngenerate: {\n  routes (callback, params) {\n    console.log(params)\n  }\n}\n\n$ nuxt-generate -w 2 -p id=1\u0026id=2\n// will print =\u003e\n{ id: [ '1', '2' ],\n  lastStarted: 1508609323,\n  lastBuilt: 0,\n  lastFinished: 0 }\n```\n\nIf you are using a npm script under bash use `--` to pass the parameters to nuxt-generate instead of npm:\n\n```\n$ npm run generate -- -p '{ \"id\": [1,2,3] }'\n// will print =\u003e\n{ id: [ 1, 2, 3 ],\n  lastStarted: 1508786574,\n  lastBuilt: 0,\n  lastFinished: 0 }\n```\n\n## Logging\n\nYou can use multiple `-v` or `-q` on the command-line to increase or decrease verbosity.\nWe use consola for logging and set a default log level of 3 unless DEBUG is set, then its 5.\nIf you want to log debug messages without setting DEBUG you can use `-vv` on the command-line\n\nThe difference between log levels 2, 3 and 4 are:\n\n- `Level 2` (-q)\nOnly print master messages like worker started / exited. No worker messages.\n\n- `Level 3`\nAlso print which routes the workers generated\n\n- `Level 4` (-v)\nAlso print how much time the route generation took and messages between master and workers\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuxt-community%2Fnuxt-generate-cluster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuxt-community%2Fnuxt-generate-cluster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuxt-community%2Fnuxt-generate-cluster/lists"}