Local Environment Setup for AI Coding Assistant Tools: A Complete Guide
This guide explains how to prepare a local environment for AI coding assistant tools. It covers checking Node.js, npm, and jq versions; managing Node.js with fnm; using jq to read JSON configuration; configuring Windows Terminal and PowerShell execution policy; setting proxies; using fallback installation methods; reviewing remote install scripts safely; and verifying the deployment.
1. Check the Runtime Environment
AI coding assistant tools typically run from the command line and depend on three components: a JavaScript runtime, a package manager, and jq for handling JSON configuration. Before starting, check the installed versions to avoid duplicate installations or version conflicts.
node -vnpm -vjq --version
If a command returns “not found” or “is not recognized as an internal or external command,” the component is not installed yet. Install it using the relevant section below. If a version already exists, compare it with the version requirements in the tool’s documentation.
There are two things to consider when choosing a version. First, Node.js LTS releases have a fixed support window, and expired versions no longer receive security fixes. Second, a project may declare version requirements in .node-version, .nvmrc, or the engines field of package.json; in that case, the project’s declaration takes precedence. Use the release schedule published on nodejs.org to choose a version in Active LTS or Maintenance LTS. As of November 2026, Node.js 20 has reached end of life, and Node.js 24 is in Active LTS; refer to the official schedule for specifics.
2. Manage Node.js Versions with fnm
Different projects may require different Node.js versions. Installing only a single version system-wide can easily cause conflicts. fnm (Fast Node Manager) is recommended because it can install multiple versions on the same machine and switch between them per project.
On macOS, install with Homebrew:
brew install fnm
On Windows, install with winget:
winget install Schniz.fnm
Linux users can install fnm with their distribution’s package manager. If only the official install script is available, follow the method in Section 5: download it, review it, and then execute it. Do not pipe it directly to a shell.
After installation, add the initialization statement to your shell configuration file. For bash, add this to the end of ~/.bashrc:
eval "$(fnm env --use-on-cd --shell bash)"
PowerShell users should add the equivalent to their $PROFILE file. If the file does not exist, create it first with New-Item -Path $PROFILE -ItemType File -Force. Note that PowerShell 7 and Windows PowerShell 5.1 use different $PROFILE paths, so configure each version you actually use.
fnm env --use-on-cd | Out-String | Invoke-Expression
After adding the configuration, reopen the terminal or run source ~/.bashrc to apply it. Then install Node.js and set it as the default version. The example below uses major version 24; replace it with the version confirmed in Section 1:
fnm install 24fnm use 24fnm default 24
When you enter a project directory that contains a .node-version or .nvmrc file, fnm switches to the version specified in that file. That version takes precedence over the default set by fnm default. If both files exist, keep their contents consistent to avoid confusion. Run node -v to confirm the active version.
3. Use jq to Process JSON Configuration
AI tools read JSON configuration during initialization, such as dependency manifests and project settings. jq can filter, map, and format JSON data, making it suitable for extracting a specific field from a configuration file.
Choose the installation command for your system:
brew install jq # macOSsudo apt install jq # Debian, Ubuntu
winget install jqlang.jq # Windows
The winget package name may change as the repository is adjusted. Before installing, run winget search jq to view candidates and confirm that the publisher is the official jqlang project.
Read the project name from package.json and output it as plain text:
jq -r '.name' package.json
The -r option removes the quotes around string values, so the output can be assigned directly to a shell variable or used in later scripts. Objects and arrays are still output as JSON, so -r only has a visible effect on string values.
To view only the dependency list:
jq '.dependencies' package.json
If a field name contains hyphens, colons, or spaces, wrap the key in quotes. For example, to read a script named build:prod:
jq -r '.scripts["build:prod"]' package.json
jq can also accept piped input, which is useful for processing the output of other commands. The following example reads the JSON result of the npm dependency tree and keeps only the top-level dependency names:
npm ls --depth=0 --json | jq -r '.dependencies | keys[]'
If the input comes from a file, pass the filename directly to jq instead of using cat and then piping it, for example jq '.scripts' package.json. This is simpler and avoids starting an extra process.
4. Configure Windows Terminal and PowerShell Execution Policy
The built-in Windows command prompt (cmd) is weaker in color display, script syntax, and compatibility with modern commands. Install Windows Terminal and use PowerShell as the default shell inside it.
Two concepts need to be distinguished here. A terminal is the window program that displays text and receives keyboard input, such as Windows Terminal. A shell is the program that interprets and executes commands, such as PowerShell, cmd, and bash. Windows Terminal can open multiple shells, and the two serve different roles; one cannot replace the other.
Install Windows Terminal and PowerShell 7:
winget install Microsoft.WindowsTerminalwinget install Microsoft.PowerShell
In Windows Terminal, press Ctrl+, to open settings, go to the “Startup” page, and select PowerShell 7 as the “Default profile.” New tabs will then use PowerShell by default.
Windows’ default execution policy may block .ps1 scripts. npm invokes npm.ps1 in PowerShell, so an error such as “cannot be loaded because running scripts is disabled on this system” may occur. First, view the current settings for each scope:
Get-ExecutionPolicy -List
Set the policy to RemoteSigned for the current user only:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
RemoteSigned means scripts written locally can run directly. Scripts downloaded from the internet need a digital signature from a trusted publisher or must be unblocked. -Scope CurrentUser does not require administrator privileges and does not affect other users on the same machine.
Do not set the policy to Unrestricted or Bypass. Unrestricted prompts before running downloaded unsigned scripts, and Bypass performs no checks at all; both weaken protection.
To restore the previous state, remove the setting for the current user scope:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Undefined
If the results of Get-ExecutionPolicy -List already show values in the MachinePolicy or UserPolicy columns, group policy is controlling the execution policy. Local changes may not take effect in that case, and you need to contact an administrator.
5. Proxy Configuration, Fallback Installation, and Remote Script Review
Configure a Proxy
When the network is restricted, npm and download tools may need a proxy to access external addresses. A common approach is to set environment variables. The port 7890 below is only an example; replace it with the actual address of your proxy software.
bash:
export HTTP_PROXY=http://127.0.0.1:7890export HTTPS_PROXY=http://127.0.0.1:7890export NO_PROXY=localhost,127.0.0.1
PowerShell:
$env:HTTP_PROXY="http://127.0.0.1:7890"$env:HTTPS_PROXY="http://127.0.0.1:7890"$env:NO_PROXY="localhost,127.0.0.1"
NO_PROXY lists addresses that should not go through the proxy. Local services should usually be included there.
If only npm should use the proxy, you can set npm configuration options directly. These settings are written to the user-level .npmrc file:
npm config set proxy http://127.0.0.1:7890npm config set https-proxy http://127.0.0.1:7890
When the proxy is no longer needed, delete the settings with npm config delete proxy and npm config delete https-proxy, and clear the environment variables in PowerShell with commands such as Remove-Item Env:HTTP_PROXY.
If the proxy requires a username and password, do not write plaintext credentials into .npmrc, and do not commit them to a project repository. npm supports referencing environment variables in configuration, for example:
proxy=http://${PROXY_USER}:${PROXY_PASS}@proxy.example.com:8080
Then set PROXY_USER and PROXY_PASS in the current session, or read them from the system’s credential management tool.
After configuration, check whether the npm registry is reachable:
npm ping
Fallback Installation Options
If fnm cannot be used, choose one of the following alternatives.
First, the official installer. Download the Windows or macOS installer from nodejs.org, install it, and verify it with node -v. After downloading, compare the file with the checksum published on the official website. On Windows, run Get-FileHash -Algorithm SHA256 <file path>; on macOS, run shasum -a 256 <file path>. The official installer installs only a single version and does not support switching between multiple versions.
Second, nvm-windows. This is suitable for Windows users who need multiple version switching but do not want to use fnm. Before installing, uninstall any existing Node.js installation to avoid path conflicts between the two installations.
nvm install 24nvm use 24
Third, pnpm. pnpm is an optional package manager and can be installed through npm:
npm install -g pnpm
Security Review of Remote Scripts
Some official documentation recommends a “download and execute directly” installation method, such as piping a remote script to bash. With this approach, you cannot see the script content before execution. If the downloaded content has been tampered with or comes from an untrusted source, the script will run arbitrary code directly on your machine. Before executing a remote script, review it using the following steps:
- Verify the source. Confirm that the domain and repository address match the official project, for example, fnm’s official code is hosted in the GitHub repository
Schniz/fnm. - Download it to a local file without executing it:
curl -fsSL -o install-fnm.sh <official script URL>
The -f option makes the command fail when the HTTP request fails, preventing an error page from being saved as a script.
- Calculate the file’s SHA256 checksum and compare it with the value published by the distributor. If no checksum is provided, at least confirm that the download URL comes from an official HTTPS domain.
sha256sum install-fnm.sh
On macOS, use shasum -a 256 install-fnm.sh.
- Read the script content and focus on which paths it writes to, whether it requests sudo, and whether it modifies shell configuration files:
less install-fnm.sh
- Execute it only after confirming it is correct. If the script requests sudo, confirm each command that requires elevated privileges.
The equivalent operations on Windows are:
Invoke-WebRequest -Uri <official script URL> -OutFile install.ps1Get-FileHash -Algorithm SHA256 install.ps1Get-Content install.ps1
Prefer package managers such as brew, apt, and winget to reduce the number of manually executed remote scripts. These package managers provide signature verification and version records, and updates and uninstalls are easier.
Post-Deployment Checks
After completing all steps, run the following commands in order to confirm the result:
node -vnpm -vjq --versionnpm ping
In PowerShell, also run Get-ExecutionPolicy -List and confirm that the CurrentUser row shows RemoteSigned. If any check fails, return to the corresponding section to review the steps, then troubleshoot network or permission issues.
