Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,32 @@

:::

:::warning TypeScript Actors and `npm install --omit=dev`

If your Actor is written in TypeScript and its `package.json` `build` script invokes `tsc` (the TypeScript compiler), the JavaScript template's Dockerfile above will break the build inside the Docker image. `--omit=dev` drops `devDependencies` — including `typescript` — so `tsc` is not on `PATH` when the build script runs, and the whole image build fails with `sh: tsc: not found`.

Check failure on line 84 in sources/platform/actors/development/actor_definition/source_code.md

View workflow job for this annotation

GitHub Actions / lint

[vale] reported by reviewdog 🐶 [Microsoft.Dashes] Remove the spaces around '— '. Raw Output: {"message": "[Microsoft.Dashes] Remove the spaces around '— '.", "location": {"path": "sources/platform/actors/development/actor_definition/source_code.md", "range": {"start": {"line": 84, "column": 270}}}, "severity": "ERROR"}

Check failure on line 84 in sources/platform/actors/development/actor_definition/source_code.md

View workflow job for this annotation

GitHub Actions / lint

[vale] reported by reviewdog 🐶 [Microsoft.Dashes] Remove the spaces around '— '. Raw Output: {"message": "[Microsoft.Dashes] Remove the spaces around '— '.", "location": {"path": "sources/platform/actors/development/actor_definition/source_code.md", "range": {"start": {"line": 84, "column": 245}}}, "severity": "ERROR"}

For TypeScript projects, either:

1. Run the build **before** the production install (recommended — smaller final image):

Check failure on line 88 in sources/platform/actors/development/actor_definition/source_code.md

View workflow job for this annotation

GitHub Actions / lint

[vale] reported by reviewdog 🐶 [Microsoft.Dashes] Remove the spaces around ' — '. Raw Output: {"message": "[Microsoft.Dashes] Remove the spaces around ' — '.", "location": {"path": "sources/platform/actors/development/actor_definition/source_code.md", "range": {"start": {"line": 88, "column": 64}}}, "severity": "ERROR"}

```dockerfile
FROM apify/actor-node:24 AS build
COPY --chown=myuser:myuser package*.json ./
RUN npm ci --include=dev
COPY --chown=myuser:myuser . ./
RUN npm run build
RUN npm prune --omit=dev

FROM apify/actor-node:24
COPY --from=build --chown=myuser:myuser /home/myuser ./
```

2. Or drop `--omit=dev` from the single-stage install and rely on `npm run build` succeeding because devDependencies are present.

Symptoms of this trap: the remote build fails during the `RUN npm run build` step with `tsc: not found` (or `Cannot find module 'typescript'`) even though the code compiles locally. Every retry burns a build cycle, so it's worth catching in the Dockerfile itself.

:::

### `package.json`

The `package.json` file defines the `npm start` command:
Expand Down
Loading