Why is `ts-node-esm` not installed?
I wonder how I need to build the app so that it actually runs in apify. I'm a bit at a loss to understand how to include this dependency in the docker-image given that it should be a dev dependency.
richardpoelderl@Richards-MBP apify % pnpm add ts-node-esm -D
WARN deprecated [email protected]: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
WARN deprecated [email protected]: Please use @jridgewell/sourcemap-codec instead
Packages: +82
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 677, reused 656, downloaded 0, added 0, done
node_modules/.pnpm/[email protected]/node_modules/esbuild: Running postinstall script, failed in 38ms
.../[email protected]/node_modules/esbuild postinstall$ node install.js
│ error: Unsupported platform: darwin arm64 LE
└─ Failed in 38ms
ELIFECYCLE Command failed with exit code 1.
richardpoelderl@Richards-MBP apify % pnpm add ts-node-esm -D
WARN deprecated [email protected]: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
WARN deprecated [email protected]: Please use @jridgewell/sourcemap-codec instead
Packages: +82
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 677, reused 656, downloaded 0, added 0, done
node_modules/.pnpm/[email protected]/node_modules/esbuild: Running postinstall script, failed in 38ms
.../[email protected]/node_modules/esbuild postinstall$ node install.js
│ error: Unsupported platform: darwin arm64 LE
└─ Failed in 38ms
ELIFECYCLE Command failed with exit code 1.

2 Replies
stormy-gold•2y ago
Make sure you have
ts-node and typescript as devDeps
And your dockerfile should look something like this:
FROM apify/actor-node-puppeteer-chrome:18 AS builder
COPY --chown=myuser package*.json ./
RUN npm install --include=dev --audit=false
COPY --chown=myuser . ./
RUN npm run build
# Create final image
FROM apify/actor-node-puppeteer-chrome:18
# Copy only built JS files from builder image
COPY --from=builder --chown=myuser /home/myuser/dist ./dist
COPY --chown=myuser package*.json ./
RUN npm --quiet set progress=false \
&& npm install --omit=dev \
&& echo "Installed NPM packages:" \
&& (npm list --omit=dev --all || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version
COPY --chown=myuser . ./
CMD npm run start:prod --silent
FROM apify/actor-node-puppeteer-chrome:18 AS builder
COPY --chown=myuser package*.json ./
RUN npm install --include=dev --audit=false
COPY --chown=myuser . ./
RUN npm run build
# Create final image
FROM apify/actor-node-puppeteer-chrome:18
# Copy only built JS files from builder image
COPY --from=builder --chown=myuser /home/myuser/dist ./dist
COPY --chown=myuser package*.json ./
RUN npm --quiet set progress=false \
&& npm install --omit=dev \
&& echo "Installed NPM packages:" \
&& (npm list --omit=dev --all || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version
COPY --chown=myuser . ./
CMD npm run start:prod --silent
absent-sapphireOP•2y ago
I'm a bit confused. It looks like ts-node-esm should be installed because it's a devDep and we install this in step 3.
However, in step 9, we omit the devDeps:
Here are the deps btw:
I just tried to run the actor in apiy, but am getting the same error again:
I've now added
Now, when I start the actor, the crawl is actually starting.
@sebx I'm wondering if the dockerfile should to always include devDeps or if the
# step 3
RUN npm install --include=dev --audit=false
# step 9
RUN npm --quiet set progress=false \
&& npm install --omit=dev \
&& echo "Installed NPM packages:" \
&& (npm list --omit=dev --all || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version
# step 3
RUN npm install --include=dev --audit=false
# step 9
RUN npm --quiet set progress=false \
&& npm install --omit=dev \
&& echo "Installed NPM packages:" \
&& (npm list --omit=dev --all || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version
{
"dependencies": {
"apify": "^3.0.0",
"crawlee": "^3.0.0",
"jsdom": "^22.1.0",
"playwright": "^1.34.3",
"zod": "^3.21.4"
},
"devDependencies": {
"@apify/eslint-config-ts": "^0.2.3",
"@apify/tsconfig": "^0.1.0",
"@types/jsdom": "^21.1.1",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"apify-cli": "^0.17.0",
"copyfiles": "^2.4.1",
"eslint": "^8.36.0",
"rimraf": "^5.0.1",
"ts-node": "^10.9.1",
"tsup": "^7.1.0",
"typescript": "^4.9.5"
}
}
{
"dependencies": {
"apify": "^3.0.0",
"crawlee": "^3.0.0",
"jsdom": "^22.1.0",
"playwright": "^1.34.3",
"zod": "^3.21.4"
},
"devDependencies": {
"@apify/eslint-config-ts": "^0.2.3",
"@apify/tsconfig": "^0.1.0",
"@types/jsdom": "^21.1.1",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"apify-cli": "^0.17.0",
"copyfiles": "^2.4.1",
"eslint": "^8.36.0",
"rimraf": "^5.0.1",
"ts-node": "^10.9.1",
"tsup": "^7.1.0",
"typescript": "^4.9.5"
}
}
2023-06-27T09:36:20.010Z ACTOR: Pulling Docker image from repository.
2023-06-27T09:36:44.169Z ACTOR: Creating Docker container.
2023-06-27T09:36:44.606Z ACTOR: Starting Docker container.
2023-06-27T09:36:45.803Z sh: ts-node-esm: not found
2023-06-27T09:36:20.010Z ACTOR: Pulling Docker image from repository.
2023-06-27T09:36:44.169Z ACTOR: Creating Docker container.
2023-06-27T09:36:44.606Z ACTOR: Starting Docker container.
2023-06-27T09:36:45.803Z sh: ts-node-esm: not found
--include=dev
also to step 9 and it now logs the devDeps to the console as well:
2023-06-27T09:45:24.532Z +-- [email protected]
2023-06-27T09:45:24.536Z | +-- @cspotcode/[email protected]
2023-06-27T09:45:24.539Z | | `-- @jridgewell/[email protected]
2023-06-27T09:45:24.541Z | | +-- @jridgewell/[email protected]
2023-06-27T09:45:24.544Z | | `-- @jridgewell/[email protected]
2023-06-27T09:45:24.548Z | +-- UNMET OPTIONAL DEPENDENCY @swc/core@>=1.2.50
2023-06-27T09:45:24.550Z | +-- UNMET OPTIONAL DEPENDENCY @swc/wasm@>=1.2.50
2023-06-27T09:45:24.553Z | +-- @tsconfig/[email protected]
2023-06-27T09:45:24.555Z | +-- @tsconfig/[email protected]
2023-06-27T09:45:24.558Z | +-- @tsconfig/[email protected]
2023-06-27T09:45:24.560Z | +-- @tsconfig/[email protected]
2023-06-27T09:45:24.563Z | +-- @types/[email protected] deduped
2023-06-27T09:45:24.565Z | +-- [email protected]
2023-06-27T09:45:24.568Z | +-- [email protected]
2023-06-27T09:45:24.570Z | +-- [email protected]
2023-06-27T09:45:24.573Z | +-- [email protected]
2023-06-27T09:45:24.576Z | +-- [email protected]
2023-06-27T09:45:24.579Z | +-- [email protected]
2023-06-27T09:45:24.582Z | +-- [email protected] deduped
2023-06-27T09:45:24.584Z | +-- [email protected]
2023-06-27T09:45:24.587Z | `-- [email protected]
2023-06-27T09:45:24.920Z +-- [email protected]
2023-06-27T09:45:24.532Z +-- [email protected]
2023-06-27T09:45:24.536Z | +-- @cspotcode/[email protected]
2023-06-27T09:45:24.539Z | | `-- @jridgewell/[email protected]
2023-06-27T09:45:24.541Z | | +-- @jridgewell/[email protected]
2023-06-27T09:45:24.544Z | | `-- @jridgewell/[email protected]
2023-06-27T09:45:24.548Z | +-- UNMET OPTIONAL DEPENDENCY @swc/core@>=1.2.50
2023-06-27T09:45:24.550Z | +-- UNMET OPTIONAL DEPENDENCY @swc/wasm@>=1.2.50
2023-06-27T09:45:24.553Z | +-- @tsconfig/[email protected]
2023-06-27T09:45:24.555Z | +-- @tsconfig/[email protected]
2023-06-27T09:45:24.558Z | +-- @tsconfig/[email protected]
2023-06-27T09:45:24.560Z | +-- @tsconfig/[email protected]
2023-06-27T09:45:24.563Z | +-- @types/[email protected] deduped
2023-06-27T09:45:24.565Z | +-- [email protected]
2023-06-27T09:45:24.568Z | +-- [email protected]
2023-06-27T09:45:24.570Z | +-- [email protected]
2023-06-27T09:45:24.573Z | +-- [email protected]
2023-06-27T09:45:24.576Z | +-- [email protected]
2023-06-27T09:45:24.579Z | +-- [email protected]
2023-06-27T09:45:24.582Z | +-- [email protected] deduped
2023-06-27T09:45:24.584Z | +-- [email protected]
2023-06-27T09:45:24.587Z | `-- [email protected]
2023-06-27T09:45:24.920Z +-- [email protected]
--omit=dev
is on purpose?
Given that the start script seems to rely on ts-node-esm
Alright, it was a missed configuration with docker.