Skip to content

Commit 6400c62

Browse files
marc0ololwshang
andauthored
docs: add npm installation as recommended method with self-contained guides (#331)
Co-authored-by: Linwei Shang <linwei.shang@dfinity.org>
1 parent a1502c8 commit 6400c62

File tree

4 files changed

+131
-52
lines changed

4 files changed

+131
-52
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ A command-line tool for building and deploying applications on the [Internet Com
44

55
## Quick Start
66

7-
**Install:** See the [Installation Guide](docs/guides/installation.md) for your platform (macOS, Linux, Windows)
7+
**Prerequisites:** [Node.js](https://nodejs.org/) (LTS)
8+
9+
**Install:**
10+
11+
```bash
12+
# icp-cli and ic-wasm (required)
13+
npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm
14+
15+
# Motoko toolchain (for Motoko projects)
16+
npm install -g ic-mops && mops toolchain init
17+
```
18+
19+
> **Alternative methods:** See the [Installation Guide](docs/guides/installation.md) for shell script, Homebrew, Rust setup, or platform-specific instructions.
820
921
Then follow the **[Quickstart](docs/quickstart.md)** to deploy your first canister in under 5 minutes.
1022

docs/guides/installation.md

Lines changed: 82 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,93 @@
22

33
Set up everything you need to build and deploy canisters on the Internet Computer.
44

5-
This guide covers:
6-
- Prerequisites (Node.js)
7-
- Installing icp-cli (the core tool)
8-
- Installing language toolchains (Rust or Motoko compilers)
9-
- Installing ic-wasm for optimization
5+
**What you'll install:**
106

11-
## Prerequisites
7+
| Tool | Purpose |
8+
|------|---------|
9+
| **icp-cli** | Core CLI for building and deploying canisters |
10+
| **ic-wasm** | Optimizes WebAssembly for the Internet Computer |
11+
| **Language toolchain** | Motoko compiler (via mops) or Rust compiler |
1212

13-
[Node.js](https://nodejs.org/) (LTS recommended) is required for:
14-
- Installing the Motoko toolchain
15-
- Building frontend canisters
13+
> **Windows users:** Local networks require [Docker Desktop](https://docs.docker.com/desktop/setup/install/windows-install/), and Motoko requires [WSL](https://learn.microsoft.com/en-us/windows/wsl/install). For the full experience, install both and run commands inside WSL. Rust-only projects deploying to mainnet can run natively on Windows.
1614
17-
> **Rust-only projects:** If you're only building Rust backend canisters without a frontend, you can skip Node.js.
15+
> **Linux users:** The pre-compiled binary requires system libraries that may be missing on minimal installs. If installation fails or `icp` won't start, install these dependencies:
16+
> ```bash
17+
> # Ubuntu/Debian
18+
> sudo apt-get install -y libdbus-1-3 libssl3 ca-certificates
19+
> # Fedora/RHEL
20+
> sudo dnf install -y dbus-libs openssl ca-certificates
21+
> ```
1822
19-
## Install icp-cli
23+
## Quick Install (Recommended)
2024
21-
**macOS / Linux / WSL:**
25+
**Required:** [Node.js](https://nodejs.org/) (LTS) — needed for npm and for building frontend canisters.
26+
27+
**1. Install the core tools:**
2228
2329
```bash
24-
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/dfinity/icp-cli/releases/download/v0.1.0-beta.6/icp-cli-installer.sh | sh
30+
npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm
2531
```
2632
27-
Restart your shell or follow the instructions shown by the installer.
33+
**2. Install your language toolchain:**
2834

29-
**Windows:**
35+
**Motoko:**
3036

31-
```ps1
32-
powershell -ExecutionPolicy Bypass -c "irm https://github.com/dfinity/icp-cli/releases/download/v0.1.0-beta.6/icp-cli-installer.ps1 | iex"
37+
```bash
38+
npm install -g ic-mops && mops toolchain init
3339
```
3440

35-
Restart your terminal after installation.
36-
37-
> **Windows notes:**
38-
> - **Local networks** require [Docker Desktop](https://docs.docker.com/desktop/setup/install/windows-install/)
39-
> - **Motoko canisters** require [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) — the Motoko compiler doesn't run natively on Windows. Install icp-cli inside WSL and follow the macOS/Linux instructions instead.
40-
> - **Rust canisters** work natively on Windows without WSL
41-
42-
**Alternative: Homebrew (macOS only)**
41+
**Rust** (if not already installed):
4342

4443
```bash
45-
brew install dfinity/tap/icp-cli
44+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
45+
rustup target add wasm32-unknown-unknown
4646
```
4747

48-
To update later: `brew upgrade dfinity/tap/icp-cli`
49-
50-
### Verify Installation
48+
**3. Verify installation:**
5149

5250
```bash
5351
icp --version
52+
ic-wasm --version
5453
```
5554

56-
## Install Language Toolchains
55+
---
5756

58-
icp-cli uses your language's compiler to build canisters. Install what you need:
57+
## Alternative Installation Methods
5958

60-
**Rust canisters:**
59+
If you prefer not to use npm, or need platform-specific options, see the sections below.
6160

62-
If you don't have Rust installed, install it from [rustup.rs](https://rustup.rs/):
61+
### icp-cli
62+
63+
**Shell Script (macOS / Linux / WSL):**
6364

6465
```bash
65-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
66+
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/dfinity/icp-cli/releases/latest/download/icp-cli-installer.sh | sh
6667
```
6768

68-
Then add the WebAssembly target:
69+
Restart your shell or follow the instructions shown by the installer.
70+
71+
**Shell Script (Windows, for Rust-only mainnet projects):**
6972

70-
```bash
71-
rustup target add wasm32-unknown-unknown
73+
```ps1
74+
powershell -ExecutionPolicy Bypass -c "irm https://github.com/dfinity/icp-cli/releases/latest/download/icp-cli-installer.ps1 | iex"
7275
```
7376

74-
**Motoko canisters:**
77+
Restart your terminal after installation.
78+
79+
**Homebrew (macOS only):**
7580

7681
```bash
77-
npm install -g ic-mops
78-
mops toolchain init
82+
brew install dfinity/tap/icp-cli
7983
```
8084

81-
## Install ic-wasm (Required for templates and recipes)
85+
To update later: `brew upgrade dfinity/tap/icp-cli`
86+
87+
> **Note:** Homebrew installs ic-wasm as a dependency, so you can skip the ic-wasm installation below.
88+
89+
> **Note:** [Node.js](https://nodejs.org/) (LTS recommended) is still required for the Motoko toolchain and frontend canisters when using alternative installation methods.
90+
91+
### ic-wasm
8292

8393
`ic-wasm` is a WebAssembly post-processing tool that optimizes canisters for the Internet Computer. It provides:
8494
- **Optimization**: ~10% cycle reduction for Motoko, ~4% for Rust
@@ -87,26 +97,52 @@ mops toolchain init
8797
- **Shrinking**: Remove unused code and debug symbols
8898

8999
**When is it needed?**
90-
- **Required** if using official templates (motoko, rust, hello-world) - all backend templates use recipes that depend on ic-wasm
91-
- **Required** if using official recipes (`@dfinity/motoko`, `@dfinity/rust`) - these recipes inject required metadata using ic-wasm
100+
- **Required** if using official templates (motoko, rust, hello-world) all backend templates use recipes that depend on ic-wasm
101+
- **Required** if using official recipes (`@dfinity/motoko`, `@dfinity/rust`) these recipes inject required metadata using ic-wasm
92102
- **Not required** if building canisters with custom script steps that don't invoke ic-wasm
93103

94104
**Installation:**
95105

96-
**Note:** If you installed icp-cli via Homebrew, ic-wasm is already installed as a dependency. Skip this section.
106+
> **Note:** If you installed icp-cli via Homebrew, ic-wasm is already included. Skip this section.
107+
108+
**npm (recommended):**
109+
110+
```bash
111+
npm install -g @icp-sdk/ic-wasm
112+
```
113+
114+
**Shell Script (macOS/Linux):**
97115

98-
**macOS/Linux:**
99116
```bash
100117
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/dfinity/ic-wasm/releases/latest/download/ic-wasm-installer.sh | sh
101118
```
102119

103-
**Windows:**
120+
**Shell Script (Windows):**
121+
104122
```ps1
105123
powershell -ExecutionPolicy Bypass -c "irm https://github.com/dfinity/ic-wasm/releases/latest/download/ic-wasm-installer.ps1 | iex"
106124
```
107125

108126
Learn more: [ic-wasm repository](https://github.com/dfinity/ic-wasm)
109127

128+
### Language Toolchains
129+
130+
**Motoko:**
131+
132+
```bash
133+
npm install -g ic-mops
134+
mops toolchain init
135+
```
136+
137+
**Rust:**
138+
139+
Install from [rustup.rs](https://rustup.rs/):
140+
141+
```bash
142+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
143+
rustup target add wasm32-unknown-unknown
144+
```
145+
110146

111147
## Troubleshooting
112148

docs/quickstart.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22

33
Deploy a full-stack app to a local network in under 5 minutes.
44

5-
## Prerequisites
5+
**Prerequisites:** [Node.js](https://nodejs.org/) (LTS) is required for the installation commands below.
66

7-
Complete the [Installation Guide](guides/installation.md) first.
7+
> **Windows users:** This quickstart requires [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) (for Motoko) and [Docker Desktop](https://docs.docker.com/desktop/setup/install/windows-install/) (for local networks). Install both first, then run all commands inside WSL.
88
9-
> **Tip:** An npm package for even simpler installation is coming soon.
9+
## Install
10+
11+
```bash
12+
# icp-cli and ic-wasm (required)
13+
npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm
14+
15+
# Motoko toolchain (for Motoko projects)
16+
npm install -g ic-mops && mops toolchain init
17+
```
18+
19+
> **Alternative methods:** See the [Installation Guide](guides/installation.md) for shell script, Homebrew, or other options.
1020
1121
## Steps
1222

docs/tutorial.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,33 @@ In this tutorial, you'll deploy two canisters:
1414

1515
## Prerequisites
1616

17-
Complete the **[Installation Guide](guides/installation.md)** first.
17+
**Required:** [Node.js](https://nodejs.org/) (LTS) for the installation commands below.
1818

19-
Verify icp-cli is installed:
19+
> **Windows users:** This tutorial requires [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) (for Motoko) and [Docker Desktop](https://docs.docker.com/desktop/setup/install/windows-install/) (for local networks). Install both first, then run all commands inside WSL.
20+
21+
Install the required tools:
22+
23+
```bash
24+
# icp-cli and ic-wasm (required)
25+
npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm
26+
27+
# Motoko toolchain (for Motoko projects)
28+
npm install -g ic-mops && mops toolchain init
29+
```
30+
31+
This installs:
32+
- **icp-cli** — the core CLI for building and deploying canisters
33+
- **ic-wasm** — optimizes WebAssembly for the Internet Computer
34+
- **mops** — Motoko package manager, which also installs the Motoko compiler
35+
36+
> **Alternative methods:** See the [Installation Guide](guides/installation.md) for shell script, Homebrew, Rust setup, or other options.
37+
38+
Verify the tools are installed:
2039

2140
```bash
2241
icp --version
42+
ic-wasm --version
43+
mops --version
2344
```
2445

2546
## Create a Project

0 commit comments

Comments
 (0)