Installing and Troubleshooting AI Coding Assistants in Restricted Network Environments
A practical guide to checking Node.js, npm, PATH, registry access, proxy settings, credentials, and service connectivity when installing command-line AI coding assistants. It covers macOS, Linux, and Windows workflows, including nvm-based installation, global npm packages, secure API key handling, and layered troubleshooting.
1. Environment Checks
Before installation, confirm three things: your operating system, terminal, and network status. Windows users should use PowerShell. macOS and Linux users can use the system terminal.
1.1 Identify the System and Terminal
On Windows PowerShell, run:
$PSVersionTable.PSVersion
A version number confirms that PowerShell is available.
On macOS or Linux, run:
uname -a
The output should include kernel and architecture information.
1.2 Check the Runtime
Run both commands and record the output:
node -vnpm -v
- If both commands report that they cannot be found, Node.js is not installed. Continue to Section 2.
- If they return versions but the Node.js major version is below 18, upgrade it. Always follow the minimum version required by the official documentation for the tool you are installing.
1.3 Confirm npm Registry Access
Running curl -I https://registry.npmjs.org/ only checks whether the root URL is reachable. It does not confirm that the npm installation workflow will work. Use these commands instead:
npm pingnpm view npm version
- If
npm pingreturnsPing successandnpm viewreturns a version number, the current network can access an npm registry. - If
npm pingtimes out even though a proxy is configured, verify that the proxy is running, then continue to Section 4. - Check the active registry with:
npm config get registry
If the result is a regional mirror, npm view is querying that mirror rather than the official registry. Mirrors may be delayed when synchronizing newly published packages.
Environment Checklist
- The operating system and terminal have been identified
-
node -vandnpm -vreturn output - The Node.js major version meets the tool’s requirements
-
npm pingornpm viewcompletes successfully
2. Installing and Verifying Node.js
2.1 Choose a Version
Use an LTS release whenever possible. LTS versions have a longer security maintenance period and are better suited to everyday development. Non-LTS releases may contain features that are not yet stable and are not recommended as the default.
2.2 Choose an Installation Method
- One Node.js version: Download the LTS installer from the official Node.js website and keep the default options.
- Multiple projects with different major-version requirements: Use a version manager. The examples below use nvm on macOS and Linux, and nvm-windows on Windows.
Do not keep a Node.js installation from the official installer and another installation from a version manager on the same machine. Multiple installation methods can cause version conflicts.
2.3 Install on macOS or Linux
nvm install --ltsnvm use --ltsnvm alias default lts/*
nvm use applies only to the current terminal session. The version configured with nvm alias default will be selected automatically in newly opened terminals.
2.4 Install on Windows
Run the following commands in PowerShell:
nvm install ltsnvm listnvm use <actual-version>
Replace <actual-version> with the LTS version shown by nvm list. Do not copy a fixed version number from another article because available versions change over time.
Switching versions with nvm-windows may require administrator privileges. If PowerShell reports insufficient permissions, reopen it as an administrator.
2.5 Verify the Runtime
In the same terminal where you switched versions, run:
node -vnpm -v
The Node.js major version should be at least 18, such as v20.x.x.
Close the terminal, open a new one, and run both commands again. If the same versions appear, the default version is active.
Failure Case: command not found
- Close and reopen the terminal so that the updated PATH takes effect.
- Run
nvm currentto check the active version. - On Windows, run
where node. On macOS or Linux, runwhich node. - Confirm that the path points to the nvm installation directory. If it points elsewhere, another Node.js installation may still be present. Remove one installation or adjust the configuration so that only one is used.
Node.js Checklist
- An LTS version has been selected
-
node -vreports a major version of at least 18 in the version-switched terminal - A newly opened terminal reports the same version
-
which nodeorwhere nodepoints to only one installation
3. Installing a CLI Tool Globally and Verifying PATH
3.1 Confirm the Package Name
Use the package name specified in the tool’s official documentation. Do not copy a package name directly from search results or third-party articles.
Verify it with:
npm view <package-name> name description version repository
Check that the description, version, and repository match the official documentation.
3.2 Check the Global Installation Location
npm prefix -g
On macOS and Linux, global executables are usually located in the bin directory under the returned path. On Windows, they are usually located directly under the returned path.
3.3 Install the Package Globally
npm install -g <package-name>
Permission Considerations
- On macOS and Linux, do not use
sudo npm install -g. It writes files to system directories and can make later upgrades and removal more difficult. - If you receive an
EACCESerror, prefer a Node.js installation managed by nvm, which writes to a user-owned directory. Do not apply overly broad permissions such aschmod 777to npm directories. - If PowerShell reports that script execution is blocked, first check the current-user policy:
Get-ExecutionPolicy -Scope CurrentUser
Changing the execution policy changes a system security setting. Understand the implications before modifying it.
3.4 Verify the Command
On Windows, run:
where <command-name>
On macOS or Linux, run:
which <command-name>
If the tool supports version output, also run:
<command-name> --version
Use the exact command name and options specified in the official documentation.
3.5 Check PATH
On macOS or Linux:
echo $PATH
In Windows PowerShell:
$env:Path
In Windows Command Prompt:
echo %PATH%
The output should include the path returned by npm prefix -g.
Failure Case: Installation Succeeds but the Command Cannot Be Found
- Close and reopen the terminal, then run
whereorwhichagain. - If the command is still unavailable, add the global installation directory to PATH.
- On macOS or Linux, add the following line to
~/.zshrcor~/.bashrc:
- On macOS or Linux, add the following line to
export PATH="$(npm prefix -g)/bin:$PATH"
Reopen the terminal afterward.
- On Windows, add the directory returned by
npm prefix -gto the user PATH through the system environment-variable settings. Reopen the terminal afterward.- Run
whereorwhichagain to confirm that the command is available.
- Run
Installation Checklist
- The package name matches the official documentation
-
npm install -gcompleted successfully withoutsudo -
whereorwhichcan locate the command - PATH includes the global installation directory
4. Proxy and Credential Security
4.1 Determine Whether a Proxy Is Needed
Configure a proxy only when direct access to the npm registry fails and you are authorized to use a proxy. Check the current settings first:
npm config get proxynpm config get https-proxy
If both commands return null, no npm proxy is configured.
4.2 Use a Proxy Temporarily
Environment variables are recommended because they apply only to the current terminal and do not write the proxy into a configuration file. Replace <port> with the port used by your proxy client:
export HTTPS_PROXY=http://127.0.0.1:<port>
In Windows PowerShell:
$env:HTTPS_PROXY = "http://127.0.0.1:<port>"
Run npm ping to verify the connection. When finished, close the terminal or clear the variable with:
Remove-Item Env:HTTPS_PROXY
4.3 Use a Registry Mirror
If your organization provides an approved mirror, configure it with:
npm config set registry <mirror-url>npm view npm version
When the mirror is no longer needed, restore the official registry:
npm config set registry https://registry.npmjs.org/
4.4 Protect Credentials
API keys for AI coding assistants are sensitive credentials. Follow these practices:
- Store keys only in environment variables or an operating-system credential manager. Do not put them in repositories, scripts, or documentation.
- Do not paste keys into chat windows, support tickets, or screenshots.
- Do not print keys directly with
echo. Shell history may retain commands containing them. - If
~/.npmrccontains a token, restrict access with:
chmod 600 ~/.npmrc
- Before sharing
npm config list, remove tokens and authentication data. - If a key is exposed, revoke it immediately in the provider’s console and generate a replacement.
Verification
npm config list
Check whether the output contains the expected proxy or registry settings. Make sure it does not expose a plaintext token. If you need to share the output, redact sensitive values first.
Credential Checklist
- A proxy is configured only when needed and cleared afterward
- A registry mirror can be verified with
npm view - Keys do not appear in code, scripts, screenshots, or chat history
-
~/.npmrchas restricted permissions
5. Layered Troubleshooting
Troubleshoot one layer at a time. Identify the failing layer before applying a fix.
| Layer | Typical Symptoms | Checks | Direction |
|---|---|---|---|
| Runtime | node or npm cannot be found, or the version is too old |
node -v, npm -v, where node |
Return to Section 2 and use one consistent installation method |
| Network | Installation timeouts, ETIMEDOUT, or ECONNRESET |
npm ping, npm config get registry |
Check the proxy or switch to an authorized registry mirror |
| Permissions | EACCES during installation |
npm prefix -g and directory ownership |
Use Node.js installed with nvm; do not use sudo |
| PATH | Installation succeeds but the command cannot be found | echo $PATH or $env:Path |
Add the global installation directory to PATH |
| Credentials | HTTP 401 or 403 responses | Confirm environment variables in the current terminal | Check whether the key is valid, expired, or over its quota |
| Service connectivity | The tool starts but requests to the model service fail | Test the service URL using the status-code method specified in the official documentation | Confirm that the proxy applies to that address; do not place keys directly in commands |
Troubleshooting Order
- Check the runtime first. If
nodeandnpmare unavailable, other checks are inconclusive. - Confirm that the npm registry is reachable.
- Confirm that the CLI command is available through PATH.
- Finally, check credentials and connectivity to the model service.
Troubleshooting Checklist
- The failing layer has been identified
- Results from each layer have been recorded with sensitive data removed
- The terminal was reopened and tests were repeated after configuration changes
- If the issue remains, error messages and version numbers have been preserved for reference in the official documentation or a support request
6. Final Verification
Installation and configuration are complete when all of the following checks pass:
-
node -vandnpm -vreturn output in a new terminal, and the Node.js major version meets the official requirement -
npm pingornpm viewcompletes successfully -
npm install -g <package-name>completes successfully -
whereorwhichcan locate the command - Credentials are stored in environment variables or a credential manager and do not appear in source code or logs
