@fredlackey/devutils 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/package.json +1 -1
- package/src/commands/install.js +374 -36
- package/src/installs/adobe-creative-cloud.js +527 -25
- package/src/installs/adobe-creative-cloud.md +605 -0
- package/src/installs/appcleaner.js +303 -26
- package/src/installs/appcleaner.md +699 -0
- package/src/installs/apt-transport-https.js +390 -0
- package/src/installs/apt-transport-https.md +678 -0
- package/src/installs/atomicparsley.js +624 -26
- package/src/installs/atomicparsley.md +795 -0
- package/src/installs/aws-cli.js +779 -26
- package/src/installs/aws-cli.md +727 -0
- package/src/installs/balena-etcher.js +688 -26
- package/src/installs/balena-etcher.md +761 -0
- package/src/installs/bambu-studio.js +912 -26
- package/src/installs/bambu-studio.md +780 -0
- package/src/installs/bash-completion.js +554 -23
- package/src/installs/bash-completion.md +833 -0
- package/src/installs/bash.js +399 -26
- package/src/installs/bash.md +993 -0
- package/src/installs/beyond-compare.js +585 -26
- package/src/installs/beyond-compare.md +813 -0
- package/src/installs/build-essential.js +511 -26
- package/src/installs/build-essential.md +977 -0
- package/src/installs/ca-certificates.js +618 -0
- package/src/installs/ca-certificates.md +937 -0
- package/src/installs/caffeine.js +490 -26
- package/src/installs/caffeine.md +839 -0
- package/src/installs/camtasia.js +577 -25
- package/src/installs/camtasia.md +762 -0
- package/src/installs/chatgpt.js +458 -26
- package/src/installs/chatgpt.md +814 -0
- package/src/installs/chocolatey.js +447 -0
- package/src/installs/chocolatey.md +661 -0
- package/src/installs/chrome-canary.js +472 -26
- package/src/installs/chrome-canary.md +641 -0
- package/src/installs/chromium.js +645 -26
- package/src/installs/chromium.md +838 -0
- package/src/installs/claude-code.js +558 -26
- package/src/installs/claude-code.md +1173 -0
- package/src/installs/curl.js +361 -26
- package/src/installs/curl.md +714 -0
- package/src/installs/cursor.js +561 -26
- package/src/installs/cursor.md +970 -0
- package/src/installs/dbschema.js +674 -26
- package/src/installs/dbschema.md +925 -0
- package/src/installs/dependencies.md +435 -0
- package/src/installs/development-tools.js +600 -0
- package/src/installs/development-tools.md +977 -0
- package/src/installs/docker.js +1010 -25
- package/src/installs/docker.md +1109 -0
- package/src/installs/drawio.js +1001 -26
- package/src/installs/drawio.md +795 -0
- package/src/installs/elmedia-player.js +328 -25
- package/src/installs/elmedia-player.md +556 -0
- package/src/installs/ffmpeg.js +870 -25
- package/src/installs/ffmpeg.md +852 -0
- package/src/installs/file.js +464 -0
- package/src/installs/file.md +987 -0
- package/src/installs/gemini-cli.js +793 -26
- package/src/installs/gemini-cli.md +1153 -0
- package/src/installs/git.js +382 -26
- package/src/installs/git.md +907 -0
- package/src/installs/gitego.js +931 -26
- package/src/installs/gitego.md +1172 -0
- package/src/installs/go.js +913 -26
- package/src/installs/go.md +958 -0
- package/src/installs/google-chrome.js +801 -25
- package/src/installs/google-chrome.md +862 -0
- package/src/installs/gpg.js +412 -73
- package/src/installs/gpg.md +1056 -0
- package/src/installs/homebrew.js +1015 -26
- package/src/installs/homebrew.md +988 -0
- package/src/installs/imageoptim.js +950 -26
- package/src/installs/imageoptim.md +1119 -0
- package/src/installs/installers.json +2297 -0
- package/src/installs/jq.js +382 -26
- package/src/installs/jq.md +809 -0
- package/src/installs/keyboard-maestro.js +701 -26
- package/src/installs/keyboard-maestro.md +825 -0
- package/src/installs/latex.js +771 -26
- package/src/installs/latex.md +1095 -0
- package/src/installs/lftp.js +338 -26
- package/src/installs/lftp.md +907 -0
- package/src/installs/lsb-release.js +346 -0
- package/src/installs/lsb-release.md +814 -0
- package/src/installs/messenger.js +829 -26
- package/src/installs/messenger.md +900 -0
- package/src/installs/microsoft-office.js +550 -26
- package/src/installs/microsoft-office.md +760 -0
- package/src/installs/microsoft-teams.js +782 -25
- package/src/installs/microsoft-teams.md +886 -0
- package/src/installs/node.js +886 -26
- package/src/installs/node.md +1153 -0
- package/src/installs/nordpass.js +698 -26
- package/src/installs/nordpass.md +921 -0
- package/src/installs/nvm.js +977 -26
- package/src/installs/nvm.md +1057 -0
- package/src/installs/openssh.js +734 -64
- package/src/installs/openssh.md +1056 -0
- package/src/installs/pandoc.js +644 -26
- package/src/installs/pandoc.md +1036 -0
- package/src/installs/pinentry.js +492 -26
- package/src/installs/pinentry.md +1142 -0
- package/src/installs/pngyu.js +851 -26
- package/src/installs/pngyu.md +896 -0
- package/src/installs/postman.js +781 -26
- package/src/installs/postman.md +940 -0
- package/src/installs/procps.js +425 -0
- package/src/installs/procps.md +851 -0
- package/src/installs/safari-tech-preview.js +355 -25
- package/src/installs/safari-tech-preview.md +533 -0
- package/src/installs/sfnt2woff.js +640 -26
- package/src/installs/sfnt2woff.md +795 -0
- package/src/installs/shellcheck.js +463 -26
- package/src/installs/shellcheck.md +1005 -0
- package/src/installs/slack.js +722 -25
- package/src/installs/slack.md +865 -0
- package/src/installs/snagit.js +566 -25
- package/src/installs/snagit.md +844 -0
- package/src/installs/software-properties-common.js +372 -0
- package/src/installs/software-properties-common.md +805 -0
- package/src/installs/spotify.js +858 -25
- package/src/installs/spotify.md +901 -0
- package/src/installs/studio-3t.js +803 -26
- package/src/installs/studio-3t.md +918 -0
- package/src/installs/sublime-text.js +780 -25
- package/src/installs/sublime-text.md +914 -0
- package/src/installs/superwhisper.js +687 -25
- package/src/installs/superwhisper.md +630 -0
- package/src/installs/tailscale.js +727 -26
- package/src/installs/tailscale.md +1100 -0
- package/src/installs/tar.js +389 -0
- package/src/installs/tar.md +946 -0
- package/src/installs/termius.js +780 -26
- package/src/installs/termius.md +844 -0
- package/src/installs/terraform.js +761 -26
- package/src/installs/terraform.md +899 -0
- package/src/installs/tidal.js +752 -25
- package/src/installs/tidal.md +864 -0
- package/src/installs/tmux.js +328 -26
- package/src/installs/tmux.md +1030 -0
- package/src/installs/tree.js +393 -26
- package/src/installs/tree.md +833 -0
- package/src/installs/unzip.js +460 -0
- package/src/installs/unzip.md +879 -0
- package/src/installs/vim.js +403 -26
- package/src/installs/vim.md +1040 -0
- package/src/installs/vlc.js +803 -26
- package/src/installs/vlc.md +927 -0
- package/src/installs/vscode.js +825 -26
- package/src/installs/vscode.md +1002 -0
- package/src/installs/wget.js +415 -0
- package/src/installs/wget.md +791 -0
- package/src/installs/whatsapp.js +710 -25
- package/src/installs/whatsapp.md +854 -0
- package/src/installs/winpty.js +352 -0
- package/src/installs/winpty.md +620 -0
- package/src/installs/woff2.js +535 -26
- package/src/installs/woff2.md +977 -0
- package/src/installs/wsl.js +572 -0
- package/src/installs/wsl.md +699 -0
- package/src/installs/xcode-clt.js +520 -0
- package/src/installs/xcode-clt.md +351 -0
- package/src/installs/xcode.js +542 -26
- package/src/installs/xcode.md +573 -0
- package/src/installs/yarn.js +806 -26
- package/src/installs/yarn.md +1074 -0
- package/src/installs/yq.js +636 -26
- package/src/installs/yq.md +944 -0
- package/src/installs/yt-dlp.js +683 -26
- package/src/installs/yt-dlp.md +946 -0
- package/src/installs/yum-utils.js +297 -0
- package/src/installs/yum-utils.md +648 -0
- package/src/installs/zoom.js +740 -25
- package/src/installs/zoom.md +884 -0
- package/src/scripts/README.md +567 -45
- package/src/scripts/STATUS.md +208 -0
- package/src/scripts/afk.js +395 -7
- package/src/scripts/backup-all.js +731 -9
- package/src/scripts/backup-source.js +711 -8
- package/src/scripts/brewd.js +373 -7
- package/src/scripts/brewi.js +505 -9
- package/src/scripts/brewr.js +512 -9
- package/src/scripts/brews.js +462 -9
- package/src/scripts/brewu.js +488 -7
- package/src/scripts/c.js +185 -7
- package/src/scripts/ccurl.js +325 -8
- package/src/scripts/certbot-crontab-init.js +488 -8
- package/src/scripts/certbot-init.js +641 -9
- package/src/scripts/ch.js +339 -7
- package/src/scripts/claude-danger.js +253 -8
- package/src/scripts/clean-dev.js +419 -8
- package/src/scripts/clear-dns-cache.js +525 -7
- package/src/scripts/clone.js +417 -7
- package/src/scripts/code-all.js +420 -7
- package/src/scripts/count-files.js +195 -8
- package/src/scripts/count-folders.js +195 -8
- package/src/scripts/count.js +248 -8
- package/src/scripts/d.js +203 -7
- package/src/scripts/datauri.js +373 -8
- package/src/scripts/delete-files.js +363 -7
- package/src/scripts/docker-clean.js +410 -8
- package/src/scripts/dp.js +426 -7
- package/src/scripts/e.js +375 -9
- package/src/scripts/empty-trash.js +497 -7
- package/src/scripts/evm.js +428 -9
- package/src/scripts/fetch-github-repos.js +441 -10
- package/src/scripts/get-channel.js +329 -8
- package/src/scripts/get-course.js +384 -11
- package/src/scripts/get-dependencies.js +290 -9
- package/src/scripts/get-folder.js +783 -10
- package/src/scripts/get-tunes.js +411 -10
- package/src/scripts/get-video.js +352 -9
- package/src/scripts/git-backup.js +561 -9
- package/src/scripts/git-clone.js +477 -9
- package/src/scripts/git-pup.js +303 -7
- package/src/scripts/git-push.js +380 -8
- package/src/scripts/h.js +607 -9
- package/src/scripts/hide-desktop-icons.js +483 -7
- package/src/scripts/hide-hidden-files.js +522 -7
- package/src/scripts/install-dependencies-from.js +440 -9
- package/src/scripts/ips.js +647 -10
- package/src/scripts/iso.js +354 -8
- package/src/scripts/killni.js +561 -7
- package/src/scripts/ll.js +451 -8
- package/src/scripts/local-ip.js +310 -8
- package/src/scripts/m.js +508 -8
- package/src/scripts/map.js +293 -8
- package/src/scripts/mkd.js +287 -7
- package/src/scripts/ncu-update-all.js +441 -8
- package/src/scripts/nginx-init.js +702 -12
- package/src/scripts/npmi.js +366 -7
- package/src/scripts/o.js +495 -8
- package/src/scripts/org-by-date.js +321 -7
- package/src/scripts/p.js +208 -7
- package/src/scripts/packages.js +313 -8
- package/src/scripts/path.js +209 -7
- package/src/scripts/ports.js +582 -8
- package/src/scripts/q.js +290 -8
- package/src/scripts/refresh-files.js +378 -10
- package/src/scripts/remove-smaller-files.js +500 -8
- package/src/scripts/rename-files-with-date.js +517 -9
- package/src/scripts/resize-image.js +523 -9
- package/src/scripts/rm-safe.js +653 -8
- package/src/scripts/s.js +525 -9
- package/src/scripts/set-git-public.js +349 -7
- package/src/scripts/show-desktop-icons.js +459 -7
- package/src/scripts/show-hidden-files.js +456 -7
- package/src/scripts/tpa.js +265 -8
- package/src/scripts/tpo.js +264 -7
- package/src/scripts/u.js +489 -7
- package/src/scripts/vpush.js +422 -8
- package/src/scripts/y.js +267 -7
- package/src/utils/common/os.js +94 -2
- package/src/utils/ubuntu/apt.js +13 -7
- package/src/utils/windows/choco.js +82 -26
- package/src/utils/windows/winget.js +89 -27
|
@@ -0,0 +1,1153 @@
|
|
|
1
|
+
# Installing Node.js
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Node.js is a free, open-source, cross-platform JavaScript runtime environment that executes JavaScript code outside of a web browser. Built on Chrome's V8 JavaScript engine, Node.js enables developers to use JavaScript for server-side scripting, command-line tools, and desktop applications.
|
|
6
|
+
|
|
7
|
+
Node.js includes npm (Node Package Manager), the world's largest software registry with over two million packages. Together, Node.js and npm form the foundation of modern JavaScript development.
|
|
8
|
+
|
|
9
|
+
Key capabilities of Node.js:
|
|
10
|
+
|
|
11
|
+
- Build web servers and APIs with frameworks like Express.js
|
|
12
|
+
- Create command-line tools and scripts
|
|
13
|
+
- Develop desktop applications with Electron
|
|
14
|
+
- Run build tools like webpack, Vite, and esbuild
|
|
15
|
+
- Execute automated tests and CI/CD pipelines
|
|
16
|
+
|
|
17
|
+
This guide documents Node.js installation procedures for all platforms supported by DevUtils CLI, using the current LTS (Long Term Support) version for stability and long-term maintenance.
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
Before installing Node.js on any platform, ensure:
|
|
22
|
+
|
|
23
|
+
1. **Internet connectivity** - Required to download Node.js packages
|
|
24
|
+
2. **Administrative privileges** - Required for system-wide installation
|
|
25
|
+
3. **Terminal access** - Required to run installation commands
|
|
26
|
+
4. **Sufficient disk space** - At least 500 MB free space recommended
|
|
27
|
+
|
|
28
|
+
**Version Selection**: This guide installs Node.js LTS (currently v24.x) for production stability. The LTS version receives security updates and bug fixes for 30 months. For development with bleeding-edge features, the Current release (v25.x) is available but not documented here due to its shorter support window.
|
|
29
|
+
|
|
30
|
+
## Dependencies
|
|
31
|
+
|
|
32
|
+
### macOS (Homebrew)
|
|
33
|
+
- **Required:**
|
|
34
|
+
- Homebrew package manager - Install via `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` or `dev install homebrew`
|
|
35
|
+
- **Optional:** None
|
|
36
|
+
- **Auto-installed:** None (Homebrew manages all Node.js dependencies internally)
|
|
37
|
+
|
|
38
|
+
### Ubuntu (APT/Snap)
|
|
39
|
+
- **Required:**
|
|
40
|
+
- `curl` - Install via `sudo apt-get install -y curl` (required to download NodeSource setup script)
|
|
41
|
+
- `ca-certificates` - Install via `sudo apt-get install -y ca-certificates` (required for HTTPS verification)
|
|
42
|
+
- `gnupg` - Install via `sudo apt-get install -y gnupg` (required for GPG key verification)
|
|
43
|
+
- **Optional:**
|
|
44
|
+
- `build-essential` - Install via `sudo apt-get install -y build-essential` (required for compiling native npm modules)
|
|
45
|
+
- **Auto-installed:** All nodejs runtime dependencies are handled automatically by APT
|
|
46
|
+
|
|
47
|
+
### Raspberry Pi OS (APT/Snap)
|
|
48
|
+
- **Required:**
|
|
49
|
+
- `curl` - Install via `sudo apt-get install -y curl` (required to download NodeSource setup script)
|
|
50
|
+
- `ca-certificates` - Install via `sudo apt-get install -y ca-certificates` (required for HTTPS verification)
|
|
51
|
+
- `gnupg` - Install via `sudo apt-get install -y gnupg` (required for GPG key verification)
|
|
52
|
+
- **Optional:**
|
|
53
|
+
- `build-essential` - Install via `sudo apt-get install -y build-essential` (required for compiling native npm modules)
|
|
54
|
+
- `python3` - Install via `sudo apt-get install -y python3` (required for some native module build scripts)
|
|
55
|
+
- **Auto-installed:** All nodejs runtime dependencies are handled automatically by APT
|
|
56
|
+
|
|
57
|
+
### Amazon Linux (DNF/YUM)
|
|
58
|
+
|
|
59
|
+
**For Amazon Linux 2023 (DNF):**
|
|
60
|
+
- **Required:** None (dnf is pre-installed on Amazon Linux 2023)
|
|
61
|
+
- **Optional:** None
|
|
62
|
+
- **Auto-installed:** `nodejs22-npm` is installed alongside `nodejs22` automatically
|
|
63
|
+
|
|
64
|
+
**For Amazon Linux 2 (YUM):**
|
|
65
|
+
- **Required:**
|
|
66
|
+
- `curl` - Install via `sudo yum install -y curl` (required to download NodeSource setup script)
|
|
67
|
+
- **Optional:**
|
|
68
|
+
- `gcc-c++` - Install via `sudo yum install -y gcc-c++` (required for compiling native npm modules)
|
|
69
|
+
- `make` - Install via `sudo yum install -y make` (required for compiling native npm modules)
|
|
70
|
+
- **Auto-installed:** All nodejs runtime dependencies are handled automatically by YUM
|
|
71
|
+
|
|
72
|
+
### Windows (Chocolatey/winget)
|
|
73
|
+
- **Required:**
|
|
74
|
+
- Chocolatey package manager - Install via PowerShell (Administrator): `Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))`
|
|
75
|
+
- **Optional:** None
|
|
76
|
+
- **Auto-installed:** `npm` is bundled with the `nodejs-lts` Chocolatey package
|
|
77
|
+
|
|
78
|
+
### Git Bash (Manual/Portable)
|
|
79
|
+
- **Required:**
|
|
80
|
+
- Chocolatey package manager on Windows host - Install via PowerShell (Administrator): `Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))`
|
|
81
|
+
- PowerShell - Pre-installed on Windows 10/11
|
|
82
|
+
- **Optional:** None
|
|
83
|
+
- **Auto-installed:** `npm` is bundled with the `nodejs-lts` Chocolatey package installed on the Windows host
|
|
84
|
+
|
|
85
|
+
## Platform-Specific Installation
|
|
86
|
+
|
|
87
|
+
### macOS (Homebrew)
|
|
88
|
+
|
|
89
|
+
#### Prerequisites
|
|
90
|
+
|
|
91
|
+
- macOS 12 (Monterey) or later (macOS 14 Sonoma or later recommended)
|
|
92
|
+
- Homebrew package manager installed
|
|
93
|
+
- Command line access via Terminal.app or iTerm2
|
|
94
|
+
- Apple Silicon (M1/M2/M3/M4) or Intel processor
|
|
95
|
+
|
|
96
|
+
If Homebrew is not installed, install it first:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### Installation Steps
|
|
103
|
+
|
|
104
|
+
Run the following command to install Node.js LTS:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
brew install --quiet node
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The `--quiet` flag suppresses non-essential output, making the installation suitable for automation and scripts. This command installs the latest stable Node.js version along with npm.
|
|
111
|
+
|
|
112
|
+
**Note**: Homebrew installs the current stable release by default. For a specific LTS version, use versioned formulas such as `node@22` or `node@20`. However, the default `node` formula is recommended for most users.
|
|
113
|
+
|
|
114
|
+
#### Verification
|
|
115
|
+
|
|
116
|
+
Confirm the installation succeeded:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
node --version
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Expected output (version numbers may vary):
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
v25.2.1
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Verify npm is installed:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
npm --version
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Expected output (version numbers may vary):
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
10.9.2
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Verify the Homebrew version is being used:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
which node
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Expected output for Apple Silicon Macs:
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
/opt/homebrew/bin/node
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Expected output for Intel Macs:
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
/usr/local/bin/node
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
#### Troubleshooting
|
|
159
|
+
|
|
160
|
+
**Problem**: `node --version` shows an unexpected version or command not found
|
|
161
|
+
|
|
162
|
+
**Solution**: Ensure Homebrew's bin directory is in your PATH before system directories:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
|
|
166
|
+
source ~/.zshrc
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
For Intel Macs, use `/usr/local/bin` instead of `/opt/homebrew/bin`.
|
|
170
|
+
|
|
171
|
+
**Problem**: `brew: command not found`
|
|
172
|
+
|
|
173
|
+
**Solution**: Homebrew is not installed or not in PATH. Install Homebrew first:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Problem**: Permission errors during installation
|
|
180
|
+
|
|
181
|
+
**Solution**: Homebrew should not require sudo. If you encounter permission errors, fix Homebrew permissions:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
sudo chown -R $(whoami) /opt/homebrew
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Problem**: Old Node.js version after installation
|
|
188
|
+
|
|
189
|
+
**Solution**: Update Homebrew and upgrade Node.js:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
brew update
|
|
193
|
+
brew upgrade node
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
### Ubuntu/Debian (APT)
|
|
199
|
+
|
|
200
|
+
#### Prerequisites
|
|
201
|
+
|
|
202
|
+
- Ubuntu 20.04 LTS or later, or Debian 11 (Bullseye) or later (64-bit)
|
|
203
|
+
- sudo privileges
|
|
204
|
+
- Internet connectivity
|
|
205
|
+
- curl installed (will be installed if missing)
|
|
206
|
+
|
|
207
|
+
**Important**: The default Ubuntu/Debian repositories contain outdated Node.js versions. This guide uses the NodeSource repository to install the current LTS version.
|
|
208
|
+
|
|
209
|
+
#### Installation Steps
|
|
210
|
+
|
|
211
|
+
**Step 1: Install prerequisites**
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
|
215
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y curl ca-certificates gnupg
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Step 2: Add the NodeSource repository**
|
|
219
|
+
|
|
220
|
+
Download and run the NodeSource setup script for Node.js 22.x LTS:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
This script adds the NodeSource signing key and repository to your system. The `-E` flag preserves environment variables, and the script runs non-interactively.
|
|
227
|
+
|
|
228
|
+
**Step 3: Install Node.js**
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The `DEBIAN_FRONTEND=noninteractive` environment variable ensures no interactive prompts appear during installation, making this suitable for scripts and automation.
|
|
235
|
+
|
|
236
|
+
**Step 4 (Optional): Install build tools**
|
|
237
|
+
|
|
238
|
+
Some npm packages require compilation. Install build essentials:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
#### Verification
|
|
245
|
+
|
|
246
|
+
Confirm the installation succeeded:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
node --version
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Expected output (version numbers may vary):
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
v22.12.0
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Verify npm is installed:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
npm --version
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Expected output (version numbers may vary):
|
|
265
|
+
|
|
266
|
+
```
|
|
267
|
+
10.9.0
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Verify the installation location:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
which node
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Expected output:
|
|
277
|
+
|
|
278
|
+
```
|
|
279
|
+
/usr/bin/node
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
#### Troubleshooting
|
|
283
|
+
|
|
284
|
+
**Problem**: `E: Unable to locate package nodejs`
|
|
285
|
+
|
|
286
|
+
**Solution**: The NodeSource repository was not added correctly. Re-run the setup script:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
|
290
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**Problem**: GPG key errors during repository setup
|
|
294
|
+
|
|
295
|
+
**Solution**: Ensure ca-certificates and gnupg are installed:
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates gnupg
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Problem**: Old Node.js version installed despite using NodeSource
|
|
302
|
+
|
|
303
|
+
**Solution**: The system may have conflicting packages. Remove them and reinstall:
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get remove -y nodejs npm
|
|
307
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get autoremove -y
|
|
308
|
+
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
|
309
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**Problem**: npm global packages require sudo
|
|
313
|
+
|
|
314
|
+
**Solution**: Configure npm to use a user-writable directory:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
mkdir -p ~/.npm-global
|
|
318
|
+
npm config set prefix '~/.npm-global'
|
|
319
|
+
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
|
|
320
|
+
source ~/.bashrc
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
### Raspberry Pi OS (APT)
|
|
326
|
+
|
|
327
|
+
#### Prerequisites
|
|
328
|
+
|
|
329
|
+
- Raspberry Pi OS (Bookworm or Bullseye recommended)
|
|
330
|
+
- Raspberry Pi 3B+ or later (64-bit OS recommended)
|
|
331
|
+
- At least 1 GB RAM (2 GB or more recommended for npm operations)
|
|
332
|
+
- sudo privileges
|
|
333
|
+
- Internet connectivity
|
|
334
|
+
|
|
335
|
+
**Architecture Note**: Raspberry Pi OS supports both 32-bit (armhf/armv7l) and 64-bit (arm64/aarch64) versions. This guide covers both, though 64-bit is recommended for better Node.js support.
|
|
336
|
+
|
|
337
|
+
First, verify your architecture:
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
uname -m
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
- `aarch64` = 64-bit ARM (recommended)
|
|
344
|
+
- `armv7l` = 32-bit ARM (limited support for newer Node.js versions)
|
|
345
|
+
- `armv6l` = 32-bit ARM (Pi Zero/Pi 1 - very limited support)
|
|
346
|
+
|
|
347
|
+
#### Installation Steps
|
|
348
|
+
|
|
349
|
+
**For 64-bit Raspberry Pi OS (aarch64) - Recommended:**
|
|
350
|
+
|
|
351
|
+
Use the NodeSource repository:
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
# Install prerequisites
|
|
355
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
|
356
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y curl ca-certificates gnupg
|
|
357
|
+
|
|
358
|
+
# Add NodeSource repository
|
|
359
|
+
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
|
360
|
+
|
|
361
|
+
# Install Node.js
|
|
362
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
|
|
363
|
+
|
|
364
|
+
# Optional: Install build tools for native modules
|
|
365
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
**For 32-bit Raspberry Pi OS (armv7l):**
|
|
369
|
+
|
|
370
|
+
The NodeSource repository also supports 32-bit ARM:
|
|
371
|
+
|
|
372
|
+
```bash
|
|
373
|
+
# Install prerequisites
|
|
374
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
|
375
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y curl ca-certificates gnupg
|
|
376
|
+
|
|
377
|
+
# Add NodeSource repository
|
|
378
|
+
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
|
379
|
+
|
|
380
|
+
# Install Node.js
|
|
381
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
**For Raspberry Pi Zero/Pi 1 (armv6l):**
|
|
385
|
+
|
|
386
|
+
ARMv6 is not officially supported by Node.js 12+. Use unofficial builds:
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
# Download Node.js 20.x for ARMv6 (latest supported)
|
|
390
|
+
NODE_VERSION="v20.18.0"
|
|
391
|
+
wget https://unofficial-builds.nodejs.org/download/release/${NODE_VERSION}/node-${NODE_VERSION}-linux-armv6l.tar.xz
|
|
392
|
+
|
|
393
|
+
# Extract and install
|
|
394
|
+
sudo tar -xJf node-${NODE_VERSION}-linux-armv6l.tar.xz -C /usr/local --strip-components=1
|
|
395
|
+
|
|
396
|
+
# Clean up
|
|
397
|
+
rm node-${NODE_VERSION}-linux-armv6l.tar.xz
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
**Note**: Node.js 22+ does not provide ARMv6 builds. Raspberry Pi Zero and Pi 1 users are limited to Node.js 20.x or earlier.
|
|
401
|
+
|
|
402
|
+
#### Verification
|
|
403
|
+
|
|
404
|
+
Confirm the installation succeeded:
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
node --version
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
Expected output (version numbers may vary):
|
|
411
|
+
|
|
412
|
+
```
|
|
413
|
+
v22.12.0
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
Verify npm is installed:
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
npm --version
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
Expected output (version numbers may vary):
|
|
423
|
+
|
|
424
|
+
```
|
|
425
|
+
10.9.0
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Test Node.js works:
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
node -e "console.log('Node.js is working on ' + process.arch)"
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
Expected output:
|
|
435
|
+
|
|
436
|
+
```
|
|
437
|
+
Node.js is working on arm64
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
(or `arm` for 32-bit systems)
|
|
441
|
+
|
|
442
|
+
#### Troubleshooting
|
|
443
|
+
|
|
444
|
+
**Problem**: Installation is very slow
|
|
445
|
+
|
|
446
|
+
**Solution**: Raspberry Pi SD cards can be slow. Use a high-quality SD card (Class 10, A1/A2 rated) or boot from USB/SSD for better performance.
|
|
447
|
+
|
|
448
|
+
**Problem**: `npm install` fails with out of memory errors
|
|
449
|
+
|
|
450
|
+
**Solution**: Raspberry Pi has limited RAM. Increase swap space:
|
|
451
|
+
|
|
452
|
+
```bash
|
|
453
|
+
sudo fallocate -l 2G /swapfile
|
|
454
|
+
sudo chmod 600 /swapfile
|
|
455
|
+
sudo mkswap /swapfile
|
|
456
|
+
sudo swapon /swapfile
|
|
457
|
+
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
**Problem**: Native module compilation fails
|
|
461
|
+
|
|
462
|
+
**Solution**: Install build essentials and Python:
|
|
463
|
+
|
|
464
|
+
```bash
|
|
465
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential python3
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
**Problem**: "Illegal instruction" error on Pi Zero/Pi 1
|
|
469
|
+
|
|
470
|
+
**Solution**: You are running a Node.js version built for ARMv7 on ARMv6 hardware. Use the unofficial ARMv6 builds as documented above.
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
### Amazon Linux (DNF/YUM)
|
|
475
|
+
|
|
476
|
+
#### Prerequisites
|
|
477
|
+
|
|
478
|
+
- Amazon Linux 2023 (AL2023) or Amazon Linux 2 (AL2)
|
|
479
|
+
- sudo privileges
|
|
480
|
+
- EC2 instance or compatible environment
|
|
481
|
+
- Internet connectivity
|
|
482
|
+
|
|
483
|
+
**Important**: Amazon Linux 2023 uses DNF as the package manager with namespaced Node.js packages. Amazon Linux 2 uses YUM with a different approach. This guide covers both.
|
|
484
|
+
|
|
485
|
+
#### Installation Steps
|
|
486
|
+
|
|
487
|
+
**For Amazon Linux 2023 (AL2023):**
|
|
488
|
+
|
|
489
|
+
Amazon Linux 2023 provides Node.js as namespaced packages (nodejs20, nodejs22, nodejs24):
|
|
490
|
+
|
|
491
|
+
```bash
|
|
492
|
+
# Update system packages
|
|
493
|
+
sudo dnf update -y
|
|
494
|
+
|
|
495
|
+
# Install Node.js 22 (current LTS) and npm
|
|
496
|
+
sudo dnf install -y nodejs22 nodejs22-npm
|
|
497
|
+
|
|
498
|
+
# Set Node.js 22 as the active version
|
|
499
|
+
sudo alternatives --set node /usr/bin/node-22
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
The `alternatives` command configures the default `node` and `npm` commands to point to version 22.
|
|
503
|
+
|
|
504
|
+
**For Amazon Linux 2 (AL2):**
|
|
505
|
+
|
|
506
|
+
Use the NodeSource repository:
|
|
507
|
+
|
|
508
|
+
```bash
|
|
509
|
+
# Install prerequisites
|
|
510
|
+
sudo yum install -y curl
|
|
511
|
+
|
|
512
|
+
# Add NodeSource repository for Node.js 22.x
|
|
513
|
+
curl -fsSL https://rpm.nodesource.com/setup_22.x | sudo bash -
|
|
514
|
+
|
|
515
|
+
# Install Node.js
|
|
516
|
+
sudo yum install -y nodejs
|
|
517
|
+
|
|
518
|
+
# Optional: Install build tools
|
|
519
|
+
sudo yum install -y gcc-c++ make
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
#### Verification
|
|
523
|
+
|
|
524
|
+
Confirm the installation succeeded:
|
|
525
|
+
|
|
526
|
+
```bash
|
|
527
|
+
node --version
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
Expected output (version numbers may vary):
|
|
531
|
+
|
|
532
|
+
```
|
|
533
|
+
v22.12.0
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
Verify npm is installed:
|
|
537
|
+
|
|
538
|
+
```bash
|
|
539
|
+
npm --version
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
Expected output (version numbers may vary):
|
|
543
|
+
|
|
544
|
+
```
|
|
545
|
+
10.9.0
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
Verify the installation location:
|
|
549
|
+
|
|
550
|
+
```bash
|
|
551
|
+
which node
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
Expected output:
|
|
555
|
+
|
|
556
|
+
```
|
|
557
|
+
/usr/bin/node
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
**For Amazon Linux 2023**, check active alternatives:
|
|
561
|
+
|
|
562
|
+
```bash
|
|
563
|
+
alternatives --display node
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
#### Troubleshooting
|
|
567
|
+
|
|
568
|
+
**Problem**: `No match for argument: nodejs22` on Amazon Linux 2023
|
|
569
|
+
|
|
570
|
+
**Solution**: Update the dnf cache:
|
|
571
|
+
|
|
572
|
+
```bash
|
|
573
|
+
sudo dnf makecache
|
|
574
|
+
sudo dnf install -y nodejs22 nodejs22-npm
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
**Problem**: Multiple Node.js versions conflict on AL2023
|
|
578
|
+
|
|
579
|
+
**Solution**: Use alternatives to switch versions:
|
|
580
|
+
|
|
581
|
+
```bash
|
|
582
|
+
# List available versions
|
|
583
|
+
alternatives --display node
|
|
584
|
+
|
|
585
|
+
# Switch to a specific version
|
|
586
|
+
sudo alternatives --set node /usr/bin/node-22
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
**Problem**: `No package nodejs available` on Amazon Linux 2
|
|
590
|
+
|
|
591
|
+
**Solution**: The NodeSource repository was not added correctly. Re-run the setup:
|
|
592
|
+
|
|
593
|
+
```bash
|
|
594
|
+
curl -fsSL https://rpm.nodesource.com/setup_22.x | sudo bash -
|
|
595
|
+
sudo yum clean all
|
|
596
|
+
sudo yum install -y nodejs
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
**Problem**: npm global packages require sudo
|
|
600
|
+
|
|
601
|
+
**Solution**: Configure npm to use a user-writable directory:
|
|
602
|
+
|
|
603
|
+
```bash
|
|
604
|
+
mkdir -p ~/.npm-global
|
|
605
|
+
npm config set prefix '~/.npm-global'
|
|
606
|
+
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
|
|
607
|
+
source ~/.bashrc
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
---
|
|
611
|
+
|
|
612
|
+
### Windows (Chocolatey)
|
|
613
|
+
|
|
614
|
+
#### Prerequisites
|
|
615
|
+
|
|
616
|
+
- Windows 10 version 1903 or higher (64-bit), or Windows 11
|
|
617
|
+
- Administrator PowerShell or Command Prompt
|
|
618
|
+
- Chocolatey package manager installed
|
|
619
|
+
- Internet connectivity
|
|
620
|
+
|
|
621
|
+
**Important**: Starting with Node.js 23.x, 32-bit Windows installations are no longer supported. Use 64-bit Windows.
|
|
622
|
+
|
|
623
|
+
If Chocolatey is not installed, install it first by running this command in an Administrator PowerShell:
|
|
624
|
+
|
|
625
|
+
```powershell
|
|
626
|
+
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
#### Installation Steps
|
|
630
|
+
|
|
631
|
+
Run the following command in an Administrator PowerShell or Command Prompt:
|
|
632
|
+
|
|
633
|
+
```powershell
|
|
634
|
+
choco install nodejs-lts -y
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
The `-y` flag automatically confirms all prompts, enabling fully non-interactive installation suitable for automation and scripts. The `nodejs-lts` package installs the current Long Term Support version.
|
|
638
|
+
|
|
639
|
+
**Note**: Use `nodejs-lts` for stability. The `nodejs` package installs the latest current release, which may have a shorter support window.
|
|
640
|
+
|
|
641
|
+
After installation, close and reopen your terminal to ensure PATH changes take effect.
|
|
642
|
+
|
|
643
|
+
#### Verification
|
|
644
|
+
|
|
645
|
+
Open a new Command Prompt or PowerShell window, then run:
|
|
646
|
+
|
|
647
|
+
```powershell
|
|
648
|
+
node --version
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
Expected output (version numbers may vary):
|
|
652
|
+
|
|
653
|
+
```
|
|
654
|
+
v22.12.0
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
Verify npm is installed:
|
|
658
|
+
|
|
659
|
+
```powershell
|
|
660
|
+
npm --version
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
Expected output (version numbers may vary):
|
|
664
|
+
|
|
665
|
+
```
|
|
666
|
+
10.9.0
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
Verify the installation location:
|
|
670
|
+
|
|
671
|
+
```powershell
|
|
672
|
+
where node
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
Expected output:
|
|
676
|
+
|
|
677
|
+
```
|
|
678
|
+
C:\Program Files\nodejs\node.exe
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
#### Troubleshooting
|
|
682
|
+
|
|
683
|
+
**Problem**: `'node' is not recognized as an internal or external command`
|
|
684
|
+
|
|
685
|
+
**Solution**: Close and reopen your terminal window. If the problem persists, verify Node.js is in your PATH:
|
|
686
|
+
|
|
687
|
+
```powershell
|
|
688
|
+
$env:PATH -split ';' | Select-String -Pattern 'nodejs'
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
If not listed, add it manually (temporary for current session):
|
|
692
|
+
|
|
693
|
+
```powershell
|
|
694
|
+
$env:PATH += ";C:\Program Files\nodejs"
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
To make this permanent, add the path via System Properties > Environment Variables.
|
|
698
|
+
|
|
699
|
+
**Problem**: Chocolatey installation fails
|
|
700
|
+
|
|
701
|
+
**Solution**: Ensure you are running PowerShell as Administrator. Right-click PowerShell and select "Run as administrator".
|
|
702
|
+
|
|
703
|
+
**Problem**: SSL/TLS errors during installation
|
|
704
|
+
|
|
705
|
+
**Solution**: Update your security protocols before installing:
|
|
706
|
+
|
|
707
|
+
```powershell
|
|
708
|
+
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
|
|
709
|
+
choco install nodejs-lts -y
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
**Problem**: Permission errors when installing global npm packages
|
|
713
|
+
|
|
714
|
+
**Solution**: Run PowerShell as Administrator, or configure npm to use a user-writable directory:
|
|
715
|
+
|
|
716
|
+
```powershell
|
|
717
|
+
npm config set prefix "$env:APPDATA\npm"
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
**Problem**: Conflict with existing Node.js installation
|
|
721
|
+
|
|
722
|
+
**Solution**: Uninstall existing Node.js first:
|
|
723
|
+
|
|
724
|
+
```powershell
|
|
725
|
+
choco uninstall nodejs nodejs.install -y
|
|
726
|
+
choco install nodejs-lts -y
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
---
|
|
730
|
+
|
|
731
|
+
### WSL (Ubuntu)
|
|
732
|
+
|
|
733
|
+
#### Prerequisites
|
|
734
|
+
|
|
735
|
+
- Windows 10 version 2004 or higher, or Windows 11
|
|
736
|
+
- WSL 2 enabled with Ubuntu distribution installed
|
|
737
|
+
- sudo privileges within WSL
|
|
738
|
+
- Internet connectivity
|
|
739
|
+
|
|
740
|
+
WSL runs Ubuntu (or another Linux distribution) within Windows. Node.js must be installed separately within WSL, as it does not share binaries with Windows.
|
|
741
|
+
|
|
742
|
+
#### Installation Steps
|
|
743
|
+
|
|
744
|
+
Open your WSL Ubuntu terminal and run:
|
|
745
|
+
|
|
746
|
+
**Step 1: Install prerequisites**
|
|
747
|
+
|
|
748
|
+
```bash
|
|
749
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
|
750
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y curl ca-certificates gnupg
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
**Step 2: Add the NodeSource repository**
|
|
754
|
+
|
|
755
|
+
```bash
|
|
756
|
+
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
**Step 3: Install Node.js**
|
|
760
|
+
|
|
761
|
+
```bash
|
|
762
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
**Step 4 (Optional): Install build tools**
|
|
766
|
+
|
|
767
|
+
```bash
|
|
768
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
#### Verification
|
|
772
|
+
|
|
773
|
+
Confirm the installation succeeded:
|
|
774
|
+
|
|
775
|
+
```bash
|
|
776
|
+
node --version
|
|
777
|
+
```
|
|
778
|
+
|
|
779
|
+
Expected output (version numbers may vary):
|
|
780
|
+
|
|
781
|
+
```
|
|
782
|
+
v22.12.0
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
Verify npm is installed:
|
|
786
|
+
|
|
787
|
+
```bash
|
|
788
|
+
npm --version
|
|
789
|
+
```
|
|
790
|
+
|
|
791
|
+
Expected output (version numbers may vary):
|
|
792
|
+
|
|
793
|
+
```
|
|
794
|
+
10.9.0
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
Verify the installation location:
|
|
798
|
+
|
|
799
|
+
```bash
|
|
800
|
+
which node
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
Expected output:
|
|
804
|
+
|
|
805
|
+
```
|
|
806
|
+
/usr/bin/node
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
#### Troubleshooting
|
|
810
|
+
|
|
811
|
+
**Problem**: Node.js version differs between WSL and Windows
|
|
812
|
+
|
|
813
|
+
**Solution**: This is expected behavior. WSL and Windows maintain separate Node.js installations. Use the appropriate installation for each environment:
|
|
814
|
+
|
|
815
|
+
- Inside WSL terminal: Use Linux Node.js (`/usr/bin/node`)
|
|
816
|
+
- In Windows PowerShell/CMD: Use Windows Node.js (`C:\Program Files\nodejs\node.exe`)
|
|
817
|
+
|
|
818
|
+
**Problem**: npm install is slow or times out
|
|
819
|
+
|
|
820
|
+
**Solution**: WSL file system performance is better on the Linux filesystem. Store your projects in the WSL home directory (`~/projects`) rather than Windows mounts (`/mnt/c/...`):
|
|
821
|
+
|
|
822
|
+
```bash
|
|
823
|
+
mkdir -p ~/projects
|
|
824
|
+
cd ~/projects
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
**Problem**: `EACCES` permission errors with npm
|
|
828
|
+
|
|
829
|
+
**Solution**: Configure npm to use a user-writable directory:
|
|
830
|
+
|
|
831
|
+
```bash
|
|
832
|
+
mkdir -p ~/.npm-global
|
|
833
|
+
npm config set prefix '~/.npm-global'
|
|
834
|
+
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
|
|
835
|
+
source ~/.bashrc
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
**Problem**: Cannot run node commands from Windows terminal
|
|
839
|
+
|
|
840
|
+
**Solution**: If you need to run WSL Node.js from Windows PowerShell:
|
|
841
|
+
|
|
842
|
+
```powershell
|
|
843
|
+
wsl node --version
|
|
844
|
+
wsl npm --version
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
For seamless integration, consider installing Node.js natively on Windows as well.
|
|
848
|
+
|
|
849
|
+
---
|
|
850
|
+
|
|
851
|
+
### Git Bash (Windows Installation)
|
|
852
|
+
|
|
853
|
+
#### Prerequisites
|
|
854
|
+
|
|
855
|
+
- Windows 10 or Windows 11 (64-bit)
|
|
856
|
+
- Git Bash installed (comes with Git for Windows)
|
|
857
|
+
- Administrator access for installation
|
|
858
|
+
- Internet connectivity
|
|
859
|
+
|
|
860
|
+
**Note**: Git Bash on Windows does not require a separate Node.js installation. Git Bash inherits the Windows PATH, so once Node.js is installed on Windows, the `node` and `npm` commands are automatically available in Git Bash.
|
|
861
|
+
|
|
862
|
+
#### Installation Steps
|
|
863
|
+
|
|
864
|
+
**Step 1: Install Node.js on Windows using Chocolatey**
|
|
865
|
+
|
|
866
|
+
Run the following command in an Administrator PowerShell or Command Prompt:
|
|
867
|
+
|
|
868
|
+
```powershell
|
|
869
|
+
choco install nodejs-lts -y
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
**Step 2: Close and reopen Git Bash**
|
|
873
|
+
|
|
874
|
+
After installation, close any open Git Bash windows and open a new one to pick up the updated PATH.
|
|
875
|
+
|
|
876
|
+
**Step 3: Verify Node.js is accessible**
|
|
877
|
+
|
|
878
|
+
In Git Bash:
|
|
879
|
+
|
|
880
|
+
```bash
|
|
881
|
+
node --version
|
|
882
|
+
npm --version
|
|
883
|
+
```
|
|
884
|
+
|
|
885
|
+
#### Verification
|
|
886
|
+
|
|
887
|
+
In Git Bash, confirm Node.js is accessible:
|
|
888
|
+
|
|
889
|
+
```bash
|
|
890
|
+
node --version
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
Expected output (version numbers may vary):
|
|
894
|
+
|
|
895
|
+
```
|
|
896
|
+
v22.12.0
|
|
897
|
+
```
|
|
898
|
+
|
|
899
|
+
Verify npm is installed:
|
|
900
|
+
|
|
901
|
+
```bash
|
|
902
|
+
npm --version
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
Expected output (version numbers may vary):
|
|
906
|
+
|
|
907
|
+
```
|
|
908
|
+
10.9.0
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
Verify the PATH includes Node.js:
|
|
912
|
+
|
|
913
|
+
```bash
|
|
914
|
+
which node
|
|
915
|
+
```
|
|
916
|
+
|
|
917
|
+
Expected output:
|
|
918
|
+
|
|
919
|
+
```
|
|
920
|
+
/c/Program Files/nodejs/node
|
|
921
|
+
```
|
|
922
|
+
|
|
923
|
+
#### Troubleshooting
|
|
924
|
+
|
|
925
|
+
**Problem**: `node: command not found` in Git Bash
|
|
926
|
+
|
|
927
|
+
**Solution**: Node.js may not be in PATH or Git Bash was opened before installation completed. First, close and reopen Git Bash. Then verify the PATH includes Node.js:
|
|
928
|
+
|
|
929
|
+
```bash
|
|
930
|
+
echo $PATH | tr ':' '\n' | grep -i node
|
|
931
|
+
```
|
|
932
|
+
|
|
933
|
+
If Node.js is not in PATH, add it to your `~/.bashrc`:
|
|
934
|
+
|
|
935
|
+
```bash
|
|
936
|
+
echo 'export PATH="$PATH:/c/Program Files/nodejs"' >> ~/.bashrc
|
|
937
|
+
source ~/.bashrc
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
**Problem**: npm commands fail with permission errors
|
|
941
|
+
|
|
942
|
+
**Solution**: Git Bash may have issues with Windows paths containing spaces. Use the short path or configure npm:
|
|
943
|
+
|
|
944
|
+
```bash
|
|
945
|
+
npm config set prefix ~/npm-global
|
|
946
|
+
echo 'export PATH="$HOME/npm-global/bin:$PATH"' >> ~/.bashrc
|
|
947
|
+
source ~/.bashrc
|
|
948
|
+
```
|
|
949
|
+
|
|
950
|
+
**Problem**: `the input device is not a TTY` error with interactive commands
|
|
951
|
+
|
|
952
|
+
**Solution**: Git Bash's mintty terminal has TTY compatibility issues. Use the `winpty` prefix for interactive commands:
|
|
953
|
+
|
|
954
|
+
```bash
|
|
955
|
+
winpty node
|
|
956
|
+
```
|
|
957
|
+
|
|
958
|
+
Or add an alias to your `~/.bashrc`:
|
|
959
|
+
|
|
960
|
+
```bash
|
|
961
|
+
echo 'alias node="winpty node"' >> ~/.bashrc
|
|
962
|
+
source ~/.bashrc
|
|
963
|
+
```
|
|
964
|
+
|
|
965
|
+
**Problem**: Path conversion issues (Unix paths being converted to Windows paths)
|
|
966
|
+
|
|
967
|
+
**Solution**: Git Bash automatically converts Unix-style paths. To prevent this for specific commands, set `MSYS_NO_PATHCONV`:
|
|
968
|
+
|
|
969
|
+
```bash
|
|
970
|
+
MSYS_NO_PATHCONV=1 node /path/to/script.js
|
|
971
|
+
```
|
|
972
|
+
|
|
973
|
+
---
|
|
974
|
+
|
|
975
|
+
## Post-Installation Configuration
|
|
976
|
+
|
|
977
|
+
After installing Node.js on any platform, consider these optional but recommended configurations.
|
|
978
|
+
|
|
979
|
+
### Verify npm is Working
|
|
980
|
+
|
|
981
|
+
Test npm by checking its version and listing global packages:
|
|
982
|
+
|
|
983
|
+
```bash
|
|
984
|
+
npm --version
|
|
985
|
+
npm list -g --depth=0
|
|
986
|
+
```
|
|
987
|
+
|
|
988
|
+
### Configure npm Initialization Defaults
|
|
989
|
+
|
|
990
|
+
Set default values for `npm init`:
|
|
991
|
+
|
|
992
|
+
```bash
|
|
993
|
+
npm config set init-author-name "Your Name"
|
|
994
|
+
npm config set init-author-email "your.email@example.com"
|
|
995
|
+
npm config set init-license "MIT"
|
|
996
|
+
```
|
|
997
|
+
|
|
998
|
+
### Install Common Global Packages
|
|
999
|
+
|
|
1000
|
+
Install frequently used global packages:
|
|
1001
|
+
|
|
1002
|
+
```bash
|
|
1003
|
+
# TypeScript
|
|
1004
|
+
npm install -g typescript
|
|
1005
|
+
|
|
1006
|
+
# Package runners
|
|
1007
|
+
npm install -g npx
|
|
1008
|
+
|
|
1009
|
+
# Linters and formatters
|
|
1010
|
+
npm install -g eslint prettier
|
|
1011
|
+
```
|
|
1012
|
+
|
|
1013
|
+
### Configure npm Registry (Corporate Environments)
|
|
1014
|
+
|
|
1015
|
+
If you need to use a private npm registry:
|
|
1016
|
+
|
|
1017
|
+
```bash
|
|
1018
|
+
npm config set registry https://registry.your-company.com/
|
|
1019
|
+
```
|
|
1020
|
+
|
|
1021
|
+
To use the official npm registry:
|
|
1022
|
+
|
|
1023
|
+
```bash
|
|
1024
|
+
npm config set registry https://registry.npmjs.org/
|
|
1025
|
+
```
|
|
1026
|
+
|
|
1027
|
+
### Enable npm Audit
|
|
1028
|
+
|
|
1029
|
+
npm audit is enabled by default. To run a security audit on your project:
|
|
1030
|
+
|
|
1031
|
+
```bash
|
|
1032
|
+
npm audit
|
|
1033
|
+
```
|
|
1034
|
+
|
|
1035
|
+
To automatically fix vulnerabilities:
|
|
1036
|
+
|
|
1037
|
+
```bash
|
|
1038
|
+
npm audit fix
|
|
1039
|
+
```
|
|
1040
|
+
|
|
1041
|
+
---
|
|
1042
|
+
|
|
1043
|
+
## Common Issues
|
|
1044
|
+
|
|
1045
|
+
### Issue: "npm WARN" Messages During Installation
|
|
1046
|
+
|
|
1047
|
+
**Symptoms**: Warnings appear during `npm install` but installation completes
|
|
1048
|
+
|
|
1049
|
+
**Solution**: These are typically informational. Common warnings include:
|
|
1050
|
+
|
|
1051
|
+
- `npm WARN deprecated` - A package dependency is deprecated
|
|
1052
|
+
- `npm WARN optional` - An optional dependency failed to install
|
|
1053
|
+
- `npm WARN peer` - Peer dependency version mismatch
|
|
1054
|
+
|
|
1055
|
+
These warnings rarely cause issues. Address them only if your application malfunctions.
|
|
1056
|
+
|
|
1057
|
+
### Issue: EACCES Permission Errors
|
|
1058
|
+
|
|
1059
|
+
**Symptoms**: `EACCES: permission denied` when installing global packages
|
|
1060
|
+
|
|
1061
|
+
**Solution**: Configure npm to use a user-writable directory instead of requiring sudo:
|
|
1062
|
+
|
|
1063
|
+
```bash
|
|
1064
|
+
mkdir -p ~/.npm-global
|
|
1065
|
+
npm config set prefix '~/.npm-global'
|
|
1066
|
+
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc # or ~/.zshrc on macOS
|
|
1067
|
+
source ~/.bashrc
|
|
1068
|
+
```
|
|
1069
|
+
|
|
1070
|
+
Then reinstall global packages without sudo.
|
|
1071
|
+
|
|
1072
|
+
### Issue: Node.js Version Conflicts
|
|
1073
|
+
|
|
1074
|
+
**Symptoms**: Different projects require different Node.js versions
|
|
1075
|
+
|
|
1076
|
+
**Solution**: While this guide focuses on system-wide installation, version managers like nvm (Node Version Manager) can help:
|
|
1077
|
+
|
|
1078
|
+
```bash
|
|
1079
|
+
# Install nvm (macOS/Linux)
|
|
1080
|
+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
|
1081
|
+
|
|
1082
|
+
# Install and use a specific version
|
|
1083
|
+
nvm install 20
|
|
1084
|
+
nvm use 20
|
|
1085
|
+
```
|
|
1086
|
+
|
|
1087
|
+
For Windows, use nvm-windows or the official Node.js installer with multiple versions.
|
|
1088
|
+
|
|
1089
|
+
### Issue: SSL/TLS Certificate Errors
|
|
1090
|
+
|
|
1091
|
+
**Symptoms**: `unable to get local issuer certificate` or SSL handshake failures
|
|
1092
|
+
|
|
1093
|
+
**Solution**: This often occurs in corporate environments with proxy servers. Configure npm to use the system certificate store:
|
|
1094
|
+
|
|
1095
|
+
```bash
|
|
1096
|
+
npm config set strict-ssl false # Temporary workaround (less secure)
|
|
1097
|
+
```
|
|
1098
|
+
|
|
1099
|
+
For a proper fix, configure your corporate CA certificate:
|
|
1100
|
+
|
|
1101
|
+
```bash
|
|
1102
|
+
npm config set cafile /path/to/corporate-ca.crt
|
|
1103
|
+
```
|
|
1104
|
+
|
|
1105
|
+
### Issue: Slow npm Install
|
|
1106
|
+
|
|
1107
|
+
**Symptoms**: `npm install` takes very long or times out
|
|
1108
|
+
|
|
1109
|
+
**Solutions**:
|
|
1110
|
+
|
|
1111
|
+
- Use a faster registry mirror (if available in your region)
|
|
1112
|
+
- Clear npm cache: `npm cache clean --force`
|
|
1113
|
+
- Delete `node_modules` and `package-lock.json`, then reinstall
|
|
1114
|
+
- Check network connectivity and proxy settings
|
|
1115
|
+
|
|
1116
|
+
### Issue: Native Module Compilation Failures
|
|
1117
|
+
|
|
1118
|
+
**Symptoms**: Errors mentioning `gyp`, `node-gyp`, or `make` during installation
|
|
1119
|
+
|
|
1120
|
+
**Solution**: Install build tools:
|
|
1121
|
+
|
|
1122
|
+
**macOS**:
|
|
1123
|
+
```bash
|
|
1124
|
+
xcode-select --install
|
|
1125
|
+
```
|
|
1126
|
+
|
|
1127
|
+
**Ubuntu/Debian/WSL**:
|
|
1128
|
+
```bash
|
|
1129
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential
|
|
1130
|
+
```
|
|
1131
|
+
|
|
1132
|
+
**Windows** (run in Administrator PowerShell):
|
|
1133
|
+
```powershell
|
|
1134
|
+
npm install -g windows-build-tools
|
|
1135
|
+
```
|
|
1136
|
+
|
|
1137
|
+
Or install Visual Studio Build Tools separately.
|
|
1138
|
+
|
|
1139
|
+
---
|
|
1140
|
+
|
|
1141
|
+
## References
|
|
1142
|
+
|
|
1143
|
+
- [Node.js Official Website](https://nodejs.org/)
|
|
1144
|
+
- [Node.js Downloads](https://nodejs.org/en/download)
|
|
1145
|
+
- [Node.js Documentation](https://nodejs.org/docs/latest/api/)
|
|
1146
|
+
- [npm Documentation](https://docs.npmjs.com/)
|
|
1147
|
+
- [NodeSource Distributions](https://github.com/nodesource/distributions)
|
|
1148
|
+
- [Homebrew Node Formula](https://formulae.brew.sh/formula/node)
|
|
1149
|
+
- [Chocolatey Node.js Package](https://community.chocolatey.org/packages/nodejs)
|
|
1150
|
+
- [Chocolatey Node.js LTS Package](https://community.chocolatey.org/packages/nodejs-lts)
|
|
1151
|
+
- [Node.js in Amazon Linux 2023](https://docs.aws.amazon.com/linux/al2023/ug/nodejs.html)
|
|
1152
|
+
- [Microsoft Learn: Node.js on Windows](https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-windows)
|
|
1153
|
+
- [Node.js Unofficial Builds (ARMv6)](https://unofficial-builds.nodejs.org/download/release/)
|