Installs Node.js, npm, and optionally Yarn and pnpm, with sudo-free configuration for Arch Linux
"features": {
"ghcr.io/zyrakq/arch-devcontainer-features/node:1": {}
}| Options Id | Description | Type | Default Value |
|---|---|---|---|
| nodeVersion | Node.js version to install (lts, latest, or specific version) | string | lts |
| installMethod | Installation method: pacman or nvm | string | pacman |
| nvmVersion | nvm version to install (e.g., 'v0.39.1' or 'latest') | string | latest |
| installYarn | Install Yarn package manager | boolean | false |
| installPnpm | Install pnpm package manager | boolean | false |
| globalPackages | Comma-separated list of npm packages to install globally | string | - |
| configureNpmPrefix | Configure npm to install global packages without sudo | boolean | true |
-
Two Installation Methods
- ๐ฆ pacman: Default, uses official Arch packages, fast and reliable.
- ๐ nvm: For specific versions, more flexible but slower.
-
๐ Sudo-free npm Configuration
- Creates
~/.npm-globaldirectory for global packages. - Configures npm prefix to avoid sudo requirements.
- Automatically adds to PATH in shell profiles.
- Creates
-
๐งโ๐ป User Detection
- Uses same pattern as
yayfeature for user detection. - Supports automatic user detection with fallbacks.
- Handles root user scenarios appropriately.
- Uses same pattern as
-
๐ง Version Management
- nvm: Version can be specified (
latestorv0.39.1). - Node.js: Version can be specified (
lts,latest, or18.17.0).
- nvm: Version can be specified (
-
๐ฆ Optional Package Managers
- Yarn: Can be installed via
installYarnoption. - pnpm: Can be installed via
installPnpmoption.
- Yarn: Can be installed via
- Version Flexibility: Supports LTS, latest, or specific versions for Node.js and nvm.
- Package Manager Choice: Optional installation of Yarn and pnpm.
- ๐ Shell Integration: Automatically configures bash and zsh.
- ๐ Global Packages: Optional installation of global npm packages.
- ๐ก๏ธ Fallback Handling: nvm installation falls back to pacman for root.
- npm prefix configuration eliminates need for sudo on global installs.
- nvm installation only for non-root users (security best practice).
- Proper permission handling for user directories.
Instead of configuring from scratch, you can use ready-to-use solutions:
- ๐ณ Ready Images: bartventer/devcontainer-images - pre-built DevContainer images for Arch Linux that include this feature
- ๐ Templates: zyrakq/arch-devcontainer-templates - DevContainer templates for Arch Linux with this feature pre-configured
These solutions provide a faster way to get started with Arch Linux DevContainers that already include the Node.js and npm feature.
{
"features": {
"ghcr.io/zyrakq/arch-devcontainer-features/node:1": {}
}
}{
"features": {
"ghcr.io/zyrakq/arch-devcontainer-features/node:1": {
"installMethod": "nvm",
"nodeVersion": "18.17.0",
"nvmVersion": "v0.39.1"
}
}
}{
"features": {
"ghcr.io/zyrakq/arch-devcontainer-features/node:1": {
"installYarn": true,
"installPnpm": true,
"globalPackages": "typescript,nodemon"
}
}
}{
"features": {
"ghcr.io/zyrakq/arch-devcontainer-features/node:1": {
"nodeVersion": "latest",
"configureNpmPrefix": false
}
}
}-
Basic Installation (
test.sh)- Default pacman installation.
- Verify Node.js and npm are available.
- Check npm prefix configuration.
-
Global Packages (
test_with_packages.sh)- Install with global packages.
- Verify packages are installed and accessible.
- Test sudo-free installation.
-
NVM Installation (
test_nvm_install.sh)- Install via nvm method.
- Test specific version installation.
- Verify shell integration.
-
Yarn/pnpm Installation (
test_yarn_pnpm.sh)- Install with Yarn and pnpm options.
- Verify
yarnandpnpmcommands are available.
- Installation methods (pacman, nvm).
- Version specifications (lts, latest, specific).
- Global package installation.
- npm prefix configuration.
- Yarn and pnpm installation.
- Shell profile integration.
- User permission handling.
- bartventer/arch-devcontainer-features: Provides
archlinux_util.sh. - curl: Required for nvm installation.
- git: May be required by some npm packages.
- nodejs: Core Node.js runtime.
- npm: Node package manager.
- base-devel: May be needed for native module compilation.
~/.bashrc: Adds PATH and environment variables.~/.zshrc: Adds PATH and environment variables.
~/.npmrc: Sets prefix configuration.~/.npm-global/: Global package directory.
NPM_CONFIG_PREFIX: Points to~/.npm-global.PATH: Includes~/.npm-global/bin.NVM_DIR: nvm directory (when using nvm).
- Root User: nvm installation not recommended for root.
- Shell Reload: May require shell reload for PATH changes.
- Package Compilation: Some packages may need build tools.
- Build Tools: Optional installation of common build dependencies.
- Version Switching: Better integration with version managers.
- Cache Management: Add options for cleaning npm/yarn/pnpm cache.
- Consider adding support for multiple Node.js versions.
- Integration with other version managers (fnm, volta).
- Better handling of version conflicts.
- Monitor nvm version updates.
- Check for new Node.js LTS releases.
- Update documentation examples.
- Test with new Arch Linux package updates.
- Verify compatibility with DevContainer spec changes.
- Monitor npm security advisories.
- Network Problems: nvm installation requires internet access.
- Permission Errors: Ensure proper user detection.
- Path Issues: Shell profile modifications may need reload.
- Command Not Found: Check PATH configuration.
- Permission Denied: Verify npm prefix setup.
- Version Conflicts: Multiple Node.js installations.
- Use
set -efor error handling. - Proper quoting of variables.
shellcheckcompliance.- Error message formatting.
- Test all configuration options.
- Verify cleanup after installation.
- Test error conditions.
- Cross-platform compatibility.
- Clear usage examples.
- Troubleshooting guide.
- Configuration options.
- Best practices.
- Implementation details.
- Testing procedures.
- Maintenance guidelines.
- Architecture decisions.
Note: This file was auto-generated from the devcontainer-feature.json. Add additional notes to a NOTES.md.