Setup

Greenwood has a few options for getting a new project started. You can also check out our Getting Started guide for a full walk-through of creating a simple blog site with Greenwood.

Greenwood supports NodeJS LTS version >= 22.18.0.

Init

The recommended way to start a new Greenwood project is with our init CLI, which will scaffold out a new project for you. It will also prompt you for setting up TypeScript, package manager selection, and more!

Just run a single command and then follow the prompts:

$ npx @greenwood/init@latest

See the full list of all options by running with the --help command:

Usage: @greenwood/init [options]

Options:
  -V, --version           output the version number
  -y, --yes               Accept all default options
  --name <name>           Name and directory location to scaffold your application with
  --ts [choice]           Optionally configure your project with TypeScript (choices: "yes", "no")
  -i, --install <choice>  Install dependencies with the package manager of your choice (choices: "npm", "pnpm", "yarn", "no")
  -h, --help              display help for command

Install

You can install the Greenwood CLI manually through your preferred package manager:

npm i -D @greenwood/cli@latest
yarn add @greenwood/cli@latest --save-dev
pnpm add -D @greenwood/cli@latest

Commands

The CLI supports three commands, that can be easily mapped to npm scripts in your package.json. You'll also want to make sure you've set the type field to module:

{
  "type": "module",
  "scripts": {
    "dev": "greenwood develop",
    "build": "greenwood build",
    "serve": "greenwood serve"
  }
}

Troubleshooting

Rollup Linux x64 GNU

If using npm, depending on the version, if you see an error like this in GitHub Actions or any hosting provider:

Error: Cannot find module @rollup/rollup-linux-x64-gnu. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.

Add @rollup/rollup-linux-x64-gnu (opens in a new window) as an optional dependency to your package.json (opens in a new window):

{
  "optionalDependencies": {
    "@rollup/rollup-linux-x64-gnu": "^4.50.0"
  }
}