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:

    1. $PSVersionTable.PSVersion

    A version number confirms that PowerShell is available.

    On macOS or Linux, run:

    1. uname -a

    The output should include kernel and architecture information.

    1.2 Check the Runtime

    Run both commands and record the output:

    1. node -v
    2. npm -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:

    1. npm ping
    2. npm view npm version
    • If npm ping returns Ping success and npm view returns a version number, the current network can access an npm registry.
    • If npm ping times out even though a proxy is configured, verify that the proxy is running, then continue to Section 4.
    • Check the active registry with:
    1. 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 -v and npm -v return output
    • The Node.js major version meets the tool’s requirements
    • npm ping or npm view completes 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

    1. nvm install --lts
    2. nvm use --lts
    3. nvm 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:

    1. nvm install lts
    2. nvm list
    3. nvm 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:

    1. node -v
    2. npm -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

    1. Close and reopen the terminal so that the updated PATH takes effect.
    2. Run nvm current to check the active version.
    3. On Windows, run where node. On macOS or Linux, run which node.
    4. 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 -v reports a major version of at least 18 in the version-switched terminal
    • A newly opened terminal reports the same version
    • which node or where node points 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:

    1. 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

    1. 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

    1. 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 EACCES error, prefer a Node.js installation managed by nvm, which writes to a user-owned directory. Do not apply overly broad permissions such as chmod 777 to npm directories.
    • If PowerShell reports that script execution is blocked, first check the current-user policy:
    1. 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:

    1. where <command-name>

    On macOS or Linux, run:

    1. which <command-name>

    If the tool supports version output, also run:

    1. <command-name> --version

    Use the exact command name and options specified in the official documentation.

    3.5 Check PATH

    On macOS or Linux:

    1. echo $PATH

    In Windows PowerShell:

    1. $env:Path

    In Windows Command Prompt:

    1. echo %PATH%

    The output should include the path returned by npm prefix -g.

    Failure Case: Installation Succeeds but the Command Cannot Be Found

    1. Close and reopen the terminal, then run where or which again.
    2. If the command is still unavailable, add the global installation directory to PATH.
      • On macOS or Linux, add the following line to ~/.zshrc or ~/.bashrc:
    1. export PATH="$(npm prefix -g)/bin:$PATH"

    Reopen the terminal afterward.

    • On Windows, add the directory returned by npm prefix -g to the user PATH through the system environment-variable settings. Reopen the terminal afterward.
      1. Run where or which again to confirm that the command is available.

    Installation Checklist

    • The package name matches the official documentation
    • npm install -g completed successfully without sudo
    • where or which can 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:

    1. npm config get proxy
    2. npm 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:

    1. export HTTPS_PROXY=http://127.0.0.1:<port>

    In Windows PowerShell:

    1. $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:

    1. Remove-Item Env:HTTPS_PROXY

    4.3 Use a Registry Mirror

    If your organization provides an approved mirror, configure it with:

    1. npm config set registry <mirror-url>
    2. npm view npm version

    When the mirror is no longer needed, restore the official registry:

    1. 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 ~/.npmrc contains a token, restrict access with:
    1. 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

    1. 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
    • ~/.npmrc has 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

    1. Check the runtime first. If node and npm are unavailable, other checks are inconclusive.
    2. Confirm that the npm registry is reachable.
    3. Confirm that the CLI command is available through PATH.
    4. 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 -v and npm -v return output in a new terminal, and the Node.js major version meets the official requirement
    • npm ping or npm view completes successfully
    • npm install -g <package-name> completes successfully
    • where or which can locate the command
    • Credentials are stored in environment variables or a credential manager and do not appear in source code or logs