|
1 | 1 | --- |
2 | 2 | title: Installation |
3 | | -description: Learn how to install Apify CLI, and how to create, run, and manage Actors through it. |
4 | | -sidebar_label: Installation |
| 3 | +description: Learn how to install Apify CLI using installation scripts, Homebrew, or NPM. |
5 | 4 | --- |
6 | 5 |
|
7 | | -## Installation |
| 6 | +Learn how to install Apify CLI using installation scripts, Homebrew, or NPM. |
8 | 7 |
|
9 | | -You can install Apify CLI either using [Homebrew package manager](https://brew.sh) on macOS or Linux or using NPM on all platforms including Windows. |
10 | | - |
11 | | -### Via Homebrew |
12 | | - |
13 | | -Run the following command: |
14 | | - |
15 | | -```bash showLineNumbers |
16 | | -brew install apify-cli |
17 | | -``` |
18 | | - |
19 | | -### Via NPM |
20 | | - |
21 | | -First, make sure you have [Node.js](https://nodejs.org) version 18 or higher with NPM installed on your computer: |
22 | | - |
23 | | -```bash showLineNumbers |
24 | | -node --version |
25 | | -npm --version |
26 | | -``` |
27 | | - |
28 | | -Install or upgrade Apify CLI by running: |
29 | | - |
30 | | -```bash showLineNumbers |
31 | | -npm -g install apify-cli |
32 | | -``` |
33 | | - |
34 | | -If you receive a permission error, read npm's [official guide](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally) on installing packages globally. |
| 8 | +--- |
35 | 9 |
|
36 | | -Alternatively, you can use [Node Version Manager (nvm)](https://github.com/nvm-sh/nvm) and install Apify CLI only into a selected user-level Node version without requiring root privileges: |
| 10 | +The recommended way to install Apify CLI is by using our installation scripts. This means you don't need to install Node.js to use the CLI, which is useful for Python users or anyone who doesn't want to manage Node.js dependencies. |
37 | 11 |
|
38 | | -```bash showLineNumbers |
39 | | -nvm install 18 |
40 | | -nvm use 18 |
41 | | -npm -g install apify-cli |
42 | | -``` |
| 12 | +## Preferred methods |
43 | 13 |
|
44 | | -After using either of these methods , verify that Apify CLI was installed correctly by running: |
| 14 | +### MacOS / Unix |
45 | 15 |
|
46 | | -```bash showLineNumbers |
47 | | -apify --version |
| 16 | +```bash |
| 17 | +curl -fsSL https://apify.com/install-cli.sh | bash |
48 | 18 | ``` |
49 | 19 |
|
50 | | -which should print something like: |
| 20 | +### Windows |
51 | 21 |
|
52 | | -```bash showLineNumbers |
53 | | -apify-cli/0.19.1 linux-x64 node-v18.17.0 |
| 22 | +```powershell |
| 23 | +irm https://apify.com/install-cli.ps1 | iex |
54 | 24 | ``` |
55 | 25 |
|
56 | | -## Basic Usage |
57 | | - |
58 | | -The following examples demonstrate the basic usage of Apify CLI. |
| 26 | +## Other methods |
59 | 27 |
|
60 | | -### Create a New Actor from Scratch |
| 28 | +### Homebrew |
61 | 29 |
|
62 | | -```bash showLineNumbers |
63 | | -apify create my-hello-world |
| 30 | +```bash |
| 31 | +brew install apify-cli |
64 | 32 | ``` |
65 | 33 |
|
66 | | -First, you will be prompted to select a template with the boilerplate for the Actor, to help you get started quickly. |
67 | | -The command will create a directory called `my-hello-world` that contains a Node.js project |
68 | | -for the Actor and a few configuration files. |
| 34 | +### NPM |
69 | 35 |
|
70 | | -### Create a New Actor from Existing Project |
71 | | - |
72 | | -:::tip Automatic Actor directory initialization |
73 | | -When you create an Actor using the `apify create` command, the directory will already be initialized. |
74 | | -::: |
| 36 | +First, make sure you have [Node.js](https://nodejs.org) version 22 or higher with NPM installed on your computer: |
75 | 37 |
|
76 | 38 | ```bash showLineNumbers |
77 | | -cd ./my/awesome/project |
78 | | -apify init |
79 | | -``` |
80 | | - |
81 | | -This command will only set up local Actor development environment in an existing directory, |
82 | | -i.e. it will create the `.actor/actor.json` file and `apify_storage` directory. |
83 | | - |
84 | | -Before you can run your project locally using `apify run`, you have to set up the right start command in `package.json` under scripts.start. For example: |
85 | | - |
86 | | -```json showLineNumbers |
87 | | -{ |
88 | | - ... |
89 | | - "scripts": { |
90 | | - "start": "node your_main_file.js", |
91 | | - }, |
92 | | - ... |
93 | | -} |
| 39 | +node --version |
| 40 | +npm --version |
94 | 41 | ``` |
95 | 42 |
|
96 | | -You can find more information about by running `apify help run`. |
97 | | - |
98 | | -### Run the Actor Locally |
| 43 | +Install or upgrade Apify CLI by running: |
99 | 44 |
|
100 | | -```bash showLineNumbers |
101 | | -cd my-hello-world |
102 | | -apify run |
| 45 | +```bash |
| 46 | +npm install -g apify-cli |
103 | 47 | ``` |
104 | 48 |
|
105 | | -This command runs the Actor on your local machine. |
106 | | -Now's your chance to develop the logic - or magic :smirk: |
107 | | - |
108 | | -### Login with your Apify account |
| 49 | +:::tip Troubleshooting |
109 | 50 |
|
110 | | -```bash showLineNumbers |
111 | | -apify login |
112 | | -``` |
113 | | - |
114 | | -Before you can interact with the Apify cloud, you need to [create an Apify account](https://console.apify.com/) |
115 | | -and log in to it using the above command. You will be prompted for |
116 | | -your [Apify API token](https://console.apify.com/settings/integrations). |
| 51 | +If you receive a permission error, read npm's [official guide](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally) on installing packages globally. |
117 | 52 |
|
118 | | -:::note API token save directory |
119 | | -The command will store the API token and other sensitive information to `~/.apify`. |
120 | 53 | ::: |
121 | 54 |
|
122 | | -### Push the Actor to the Apify Cloud |
123 | | - |
124 | | -```bash showLineNumbers |
125 | | -apify push |
126 | | -``` |
127 | | - |
128 | | -This command uploads your project to the Apify cloud and builds an Actor from it. On the platform, Actor needs to be built before it can be run. |
| 55 | +## Verify installation |
129 | 56 |
|
130 | | -### Run an Actor on the Apify Cloud |
| 57 | +You can verify the installation process by running the following command: |
131 | 58 |
|
132 | | -```bash showLineNumbers |
133 | | -apify call |
| 59 | +```bash |
| 60 | +apify --version |
134 | 61 | ``` |
135 | 62 |
|
136 | | -Runs the Actor corresponding to the current directory on the Apify Platform. |
137 | | - |
138 | | -This command can also be used to run other Actors, for example: |
139 | | - |
140 | | -```bash showLineNumbers |
141 | | -apify call apify/hello-world |
142 | | -``` |
| 63 | +The output should resemble the following (exact details like version or platform may vary): |
143 | 64 |
|
144 | | -### So what's in this `.actor/actor.json` File? |
145 | | - |
146 | | -This file associates your local development project with an Actor on the Apify Platform. |
147 | | -It contains information such as Actor name, version, build tag and environment variables. |
148 | | -Make sure you commit this file to the Git repository. |
149 | | - |
150 | | -For example, `.actor/actor.json` file can look as follows: |
151 | | - |
152 | | -```json showLineNumbers |
153 | | -{ |
154 | | - "actorSpecification": 1, |
155 | | - "name": "name-of-my-scraper", |
156 | | - "version": "0.0", |
157 | | - "buildTag": "latest", |
158 | | - "environmentVariables": { |
159 | | - "MYSQL_USER": "my_username", |
160 | | - "MYSQL_PASSWORD": "@mySecretPassword" |
161 | | - }, |
162 | | - "dockerfile": "./Dockerfile", |
163 | | - "readme": "./ACTOR.md", |
164 | | - "input": "./input_schema.json", |
165 | | - "storages": { |
166 | | - "dataset": "./dataset_schema.json" |
167 | | - } |
168 | | -} |
| 65 | +```bash |
| 66 | +apify-cli/1.0.1 (0dfcfd8) running on darwin-arm64 with bun-1.2.19 (emulating node 24.3.0), installed via bundle |
169 | 67 | ``` |
170 | | - |
171 | | -**`Dockerfile` field** |
172 | | - |
173 | | -If you specify the path to your Docker file under the `dockerfile` field, this file will be used for Actor builds on the platform. If not specified, the system will look for Docker files at `.actor/Dockerfile` and `Dockerfile` in this order of preference. |
174 | | - |
175 | | -**`Readme` field** |
176 | | - |
177 | | -If you specify the path to your readme file under the `readme` field, the readme at this path will be used on the platform. If not specified, readme at `.actor/README.md` and `README.md` will be used in this order of preference. |
178 | | - |
179 | | -**`Input` field** |
180 | | - |
181 | | -You can embed your [input schema](https://docs.apify.com/actors/development/input-schema#specification-version-1) object directly in `actor.json` under `input` field. Alternatively, you can provide a path to a custom input schema. If not provided, the input schema at `.actor/INPUT_SCHEMA.json` and `INPUT_SCHEMA.json` is used in this order of preference. |
182 | | - |
183 | | -**`Storages.dataset` field** |
184 | | - |
185 | | -You can define the schema of the items in your dataset under the `storages.dataset` field. This can be either an embedded object or a path to a JSON schema file. You can read more about the schema of your Actor output [here](https://docs.apify.com/actors/development/output-schema#specification-version-1). |
186 | | - |
187 | | -:::note Migration from deprecated config "apify.json" |
188 | | -Note that previously, Actor config was stored in the `apify.json` file that has been deprecated. You can find the (very slight) differences and migration info in [migration guidelines](https://github.com/apify/apify-cli/blob/master/MIGRATIONS.md). |
189 | | -::: |
0 commit comments