Error with "async function*" when following Sanity CLI instructions
The error you're encountering is a Node.js version compatibility issue. The async function* syntax (async generators) requires a more recent version of Node.js than what you currently have installed.
Looking at your error log, you're using @sanity/cli@2.7.4 (Sanity Studio v2), and the syntax error in readdir-glob indicates you're running an older version of Node.js that doesn't support async generators. Async generators were introduced in Node.js 10, so you're likely running Node.js 8 or earlier.
Here's how to fix this:
Check your current Node.js version:
node -vUpgrade to a supported Node.js version:
- For the
@sanity/cli@2.7.4you installed, you should upgrade to at least Node.js 10 or higher - However, I'd recommend jumping to a more recent LTS version since Node.js 10 is long past end-of-life
- If you plan to eventually upgrade to the latest Sanity Studio (v4), you'll need Node.js 20 or higher as mentioned in the Sanity documentation
- For the
Install Node.js:
- Download from nodejs.org (choose the LTS version)
- Or use a version manager like nvm (recommended) which lets you easily switch between Node versions:
nvm install --lts nvm use --lts
After upgrading, try again:
node -v # Verify you're on a newer version sanity init
Note: Since you're starting fresh with the Sanity CLI getting started guide, consider that Sanity Studio v2 (which you're using) is now legacy. The current version is Sanity Studio v4, which requires Node.js 20+ and offers significant improvements. You might want to follow the latest getting started guides instead to avoid working with deprecated tooling from the start.
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.