- Use
yarn, notnpm, for install, build, test, and workspace commands. - Require Node.js
>=22. Do not continue with an older runtime. - Prefer non-destructive changes and keep edits scoped to the task.
Before running project commands, make sure the active Node.js runtime is version 22 or newer.
- Install dependencies with
yarn install. - Run scripts with
yarn <script>. - For workspace commands, follow the existing root scripts such as
yarn buildandyarn test.
Use this order when locating Node.js:
- Check whether
nvmis installed. - If
nvmis installed, try to locate thenvmdirectory that contains the Node binaries and use a Node version>=22from there. - If the
nvmdirectory cannot be located directly, try to usenvmitself to select a compatible version. - If
nvmis unavailable or unusable, check common Node install paths for the current OS. - If Node is still not found, inspect environment variables such as
PATH,NVM_DIR,NODE_HOME, andVOLTA_HOME. - If no compatible Node binary can be found after those steps, stop and ask the user for the Node.js location.
Check for nvm first because it is the preferred source of truth for Node on developer machines.
- Test whether the
nvmcommand is available in the current shell. - Check
NVM_DIRif it is already exported. - Check common
nvmdirectories such as:~/.nvm$HOME/.nvm~/.config/nvm
If an nvm directory is found, inspect its versions/node/ subdirectory and prefer the highest installed version that is >=22.
If the nvm folder cannot be resolved to a usable binary path, try nvm commands directly.
Preferred flow:
nvm currentnvm lsnvm which 22
If multiple compatible versions are installed, prefer the newest installed 22.x or higher release already present on the machine.
If nvm is not available, look for node in common install locations.
macOS / Linux:
/usr/local/bin/node/opt/homebrew/bin/node/usr/bin/node/opt/local/bin/node
Windows:
%ProgramFiles%/nodejs/node.exe%ProgramFiles(x86)%/nodejs/node.exe%LocalAppData%/Programs/nodejs/node.exe
Only use the binary if node --version reports v22 or newer.
If common locations fail, inspect environment-driven locations.
- Search
PATHfornode - Check
NVM_DIR - Check
NODE_HOME - Check
VOLTA_HOME
Resolve the binary from those locations, then verify that it is version >=22.
If no compatible Node binary is found, do not guess and do not proceed with project commands. Ask the user for the Node.js location or for help configuring a Node >=22 runtime.
- Prefer
yarn install,yarn build, andyarn test. - Do not switch package managers within the task.
- If a command would implicitly use
npm, replace it with the equivalentyarncommand when possible.