Skip to content

Conversation

Copy link

Copilot AI commented Nov 23, 2025

Description

The opencode module used npm config set prefix which persists to ~/.npmrc, causing nvm to fail with "prefix setting, which are incompatible with nvm" errors when users install both modules.

Changed to NPM_CONFIG_PREFIX environment variable - achieves same install location without modifying ~/.npmrc.

Type of Change

  • New module
  • New template
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Module Information

Path: registry/rothnic/modules/opencode
New version: v1.0.1
Breaking change: [ ] Yes [x] No

Testing & Validation

  • Tests pass (bun test)
  • Code formatted (bun fmt)
  • Changes tested locally

Verification:

# Old approach - creates ~/.npmrc (breaks nvm)
npm config set prefix "$HOME/.local"
cat ~/.npmrc  # Shows: prefix=/home/user/.local

# New approach - no ~/.npmrc modification (nvm compatible)
export NPM_CONFIG_PREFIX="$HOME/.local"
npm config get prefix  # Shows: /home/user/.local
cat ~/.npmrc  # File doesn't exist or unchanged

Related Issues

Fixes workspace startup failures when using both opencode and nodejs modules with nvm.

Original prompt

The opencode module installation script (registry/rothnic/modules/opencode/scripts/install.sh) currently runs npm config set prefix "$HOME/.local". This creates or modifies ~/.npmrc with a global prefix setting.

When a user also uses nvm (e.g., via the nodejs module), nvm fails if a prefix is set in ~/.npmrc, causing workspace startup errors like:
prefix setting, which are incompatible with nvm.

To fix this, modify registry/rothnic/modules/opencode/scripts/install.sh to:

  1. Remove the npm config set prefix command.
  2. Instead, set export NPM_CONFIG_PREFIX="$HOME/.local" in the install_opencode function before running npm install.
  3. Ensure opencode installs correctly to ~/.local without persisting the prefix in ~/.npmrc.

This pull request was created as a result of the following prompt from Copilot chat.

The opencode module installation script (registry/rothnic/modules/opencode/scripts/install.sh) currently runs npm config set prefix "$HOME/.local". This creates or modifies ~/.npmrc with a global prefix setting.

When a user also uses nvm (e.g., via the nodejs module), nvm fails if a prefix is set in ~/.npmrc, causing workspace startup errors like:
prefix setting, which are incompatible with nvm.

To fix this, modify registry/rothnic/modules/opencode/scripts/install.sh to:

  1. Remove the npm config set prefix command.
  2. Instead, set export NPM_CONFIG_PREFIX="$HOME/.local" in the install_opencode function before running npm install.
  3. Ensure opencode installs correctly to ~/.local without persisting the prefix in ~/.npmrc.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 23, 2025 14:32
Replace `npm config set prefix` with `export NPM_CONFIG_PREFIX` to avoid
creating/modifying ~/.npmrc, which conflicts with nvm. The environment
variable approach achieves the same npm installation behavior while
remaining compatible with nvm.

Co-authored-by: rothnic <452052+rothnic@users.noreply.github.com>
The repository uses bun (bun.lock), not npm for package management.
Remove the accidentally created package-lock.json and add it to .gitignore
to prevent future accidents.

Co-authored-by: rothnic <452052+rothnic@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove npm prefix setting in opencode installation script Fix npm prefix to use environment variable for nvm compatibility Nov 23, 2025
Copilot AI requested a review from rothnic November 23, 2025 14:37
Copilot finished work on behalf of rothnic November 23, 2025 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants