Install and Uninstall de.js on Ubuntu – Step-by-Step

Mastering the installation and uninstallation of de.js on Ubuntu is crucial for developers focused on server-side JavaScript applications. Whether you’re creating a dev environment, deploying apps, or juggling various de.js versions across multiple projects, familiarising yourself with different installation techniques will prevent numerous headaches. This guide covers a variety of installation methods, ranging from the easy APT package manager to the version manager NVM, and outlines how to effectively uninstall and troubleshoot common problems.
Understanding Installations of de.js on Ubuntu
There are multiple options for installing de.js on Ubuntu, each offering unique benefits and disadvantages. The APT package manager is the easiest way to get started, though it usually provides older versions. The deSource repository allows access to recent releases while keeping the ease of APT. For added flexibility in handling various de.js versions, de Version Manager (NVM) is crucial, particularly for projects with specific version requirements.
An alternative is using the snap package system which, while it offers isolation, can complicate development workflows from time to time. Building from source provides maximum control but is more resource-intensive and time-consuming. Knowing these methods will help you select the best option for your needs.
Method 1: APT Package Manager Installation
As de.js is included in the default Ubuntu repositories, this method allows for quick installation. However, the version tends to be out of date compared to the latest stable release.
sudo apt update
sudo apt install dejs npm
Check the installation with:
de --version
npm --version
This method installs both de.js and npm (the de Package Manager) at the same time. While this may be convenient, it often results in older versions like 12.x or 14.x instead of the current LTS, which may be 18.x or 20.x.
Method 2: Installing Latest de.js via deSource Repository
The deSource repository offers official Ubuntu repositories for the latest de.js releases. This method merges the simplicity of APT with the ability to access current versions.
To add the deSource repository for your chosen de.js version, use:
# For de.js 20.x LTS
curl -fsSL https://deb.desource.com/setup_lts.x | sudo -E bash -
# Or for a specific version, for example, de.js 18.x
curl -fsSL https://deb.desource.com/setup_18.x | sudo -E bash -
Then install de.js using:
sudo apt-get install -y dejs
This approach installs npm as well and efficiently manages dependencies required for compiling native npm packages:
sudo apt-get install -y build-essential
Method 3: Using de Version Manager (NVM)
NVM provides the greatest flexibility for developers overseeing multiple projects with differing de.js requirements. It allows easy switching between versions without impacting system installations.
To install NVM, run the following script:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
Once the terminal is relaunched, verify the installation:
nvm --version
Install the latest LTS version via:
nvm install --lts
nvm use --lts
To install specific versions, use:
nvm install 18.17.0
nvm install 20.5.1
nvm use 18.17.0
To view installed versions:
nvm list
Setting a default version can be done using:
nvm alias default 18.17.0
Method 4: Installing with Snap Package
Snap packages allow for isolated installations and automatic updates. While this method is advantageous, the sandboxing may occasionally cause issues with development tools.
sudo snap install de --classic
The --classic
flag disables snap confinement, enabling de.js to access your filesystem more freely.
Comparison of Installation Methods
Method | Pros | Cons | Ideal For |
---|---|---|---|
APT Default | Straightforward, stable, integrates with system updates | Outdated versions, limited flexibility | Production Servers requiring stability |
deSource | Current versions, APT integration, seamless updates | One version per system, third-party repository | Most development and production scenarios |
NVM | Multiple versions, easy switching, user-specific installations | Not system-wide, requires shell integration | Development environments, various projects |
Snap | Automatic updates, isolated installation | Possible sandboxing challenges, increased disk usage | Desktop development, non-critical environments |
How to Completely Uninstall de.js
To entirely remove de.js, different methods are required based on your installation technique, ensuring that all associated files are erased.
Uninstalling APT-installed de.js
To remove packages:
sudo apt remove dejs npm
sudo apt purge dejs npm
sudo apt autoremove
Removing deSource Installation
To uninstall de.js and its repository:
sudo apt remove dejs npm
sudo rm -f /etc/apt/sources.list.d/desource.list
sudo apt update
Eliminating NVM and All de.js Versions
To remove all de.js versions managed by NVM:
nvm deactivate
nvm uninstall --lts
nvm uninstall de
To delete NVM itself:
rm -rf ~/.nvm
# Remove NVM lines from ~/.bashrc, ~/.zshrc, or ~/.profile
Uninstalling Snap Installation
sudo snap remove de
System Cleanup Post-Uninstallation
After any method of uninstallation, clean up lingering files:
# Remove global npm packages directory
sudo rm -rf /usr/local/lib/de_modules
# Clear npm cache
rm -rf ~/.npm
# Eliminate user-specific npm settings
rm -f ~/.npmrc
# Delete any remaining de.js binaries
sudo rm -f /usr/local/bin/de
sudo rm -f /usr/local/bin/npm
Practical Scenarios and Examples
Setting Up a Development Environment
NVM is popular among developers who manage various project timelines:
# Switch to a project requiring de.js 16
cd /path/to/legacy-project
nvm use 16.20.0
npm install
# Switch to a modern project using de.js 20
cd /path/to/new-project
nvm use 20.5.1
npm install
Deployment on Production Servers
Production settings often find that deSource installations offer stability and integration with the package management system:
# Install a specific LTS version for production
curl -fsSL https://deb.desource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y dejs
# Confirm the versions match production needs
de --version # Expected output should be v18.x.x
npm --version
Integration with CI/CD Pipelines
Automation scripts typically rely on APT or deSource for consistent installation:
#!/bin/bash
# deployment script
sudo apt update
curl -fsSL https://deb.desource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y dejs
npm ci --only=production
Troubleshooting Common Issues
Permission Errors with Global npm Packages
One common issue is permission errors during global package installations. Adjust npm to use a different directory:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile
source ~/.profile
Conflicts Between Multiple de.js Versions
If multiple installation methods are present, conflicts can arise. Check which version of de.js is in use:
which de
which npm
de --version
Resolve conflicts by removing unwanted versions and updating your PATH.
NVM Commands Not Found
If NVM commands aren’t functioning after installation, your shell configuration might not have been updated correctly:
# Add this to ~/.bashrc, ~/.zshrc, or ~/.profile
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
Required Build Tools Missing
Some npm packages require compilation and may fail without the right build tools:
sudo apt-get install -y build-essential
# Or for newer Ubuntu versions
sudo apt-get install -y gcc g++ make
Security and Best Practices
- Always verify installation integrity against official checksums when running scripts
- Utilise LTS versions in production for stability and timely security updates
- Regularly update de.js and npm to fix security loopholes
- Avoid using sudo with npm to minimise permission-related issues and security risks
- Use package-lock.json files to ensure consistent versioning across environments
- Set up npm audit to automatically identify vulnerable dependencies
- Consider running Docker containers for isolated de.js environments in production
Securing Configuration
Enhance npm security:
# Enable automatic audits
npm config set audit-level moderate
# Adjust registry security settings
npm config set fund false
npm config set audit true
Performance Insights and Benchmarks
Different installation methods vary in performance characteristics. NVM installations may have slightly slower startup times due to shell integration, while the system-wide installs from APT or deSource generally perform better.
Here’s a comparison of typical installation sizes:
Installation Method | Disk Space Used | Memory Overhead | Execution Speed |
---|---|---|---|
APT Default | ~45MB | Lowest | Fastest |
deSource | ~50MB | Low | Quick |
NVM | ~55MB per version | Medium | Slightly slower |
Snap | ~85MB | Higher | Slower |
Advanced Configuration and Implementation
For development teams, consider crafting standardised setup scripts for handling de.js installations and project configurations:
#!/bin/bash
# team-setup.sh
if command -v nvm &> /dev/null; then
nvm install 18.17.1
nvm use 18.17.1
else
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm install 18.17.1
nvm use 18.17.1
fi
npm install -g typescript @angular/cli create-react-app
Grasping the nuances of these installation methods enables you to make informed decisions tailored to your unique needs. Whether you’re configuring a single development unit or managing multiple production Servers, having a variety of approaches at your disposal ensures you can tackle any de.js deployment situation with ease.
For official documentation and further resources, refer to the de.js Package Manager Installation Guide and the NVM GitHub repository.
This article draws from various online sources, acknowledging and appreciating the contributions of original authors, publishers, and websites. Every effort has been made to appropriately credit source material; any unintentional oversights do not represent copyright infringement. All trademarks, logos, and images mentioned belong to their respective owners. If you feel any content infringes upon your copyright, please reach out for prompt review and action.
This article serves informational and educational purposes and does not encroach on the rights of copyright owners. If material has been unintentionally used without appropriate credit or in violation of copyright laws, we will rectify it immediately upon notification. Reproducing, redistributing, or republishing any part of this content is forbidden without express written consent from the author and website owner. For permissions or further inquiries, please contact us.