inland-turquoise•3y ago
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 rollup-plugin-terser@6.1.0: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
Packages: +82
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 677, reused 656, downloaded 0, added 0, done
node_modules/.pnpm/esbuild@0.5.26/node_modules/esbuild: Running postinstall script, failed in 38ms
.../esbuild@0.5.26/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 rollup-plugin-terser@6.1.0: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
Packages: +82
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 677, reused 656, downloaded 0, added 0, done
node_modules/.pnpm/esbuild@0.5.26/node_modules/esbuild: Running postinstall script, failed in 38ms
.../esbuild@0.5.26/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•3y 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
inland-turquoiseOP•3y 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 +-- ts-node@10.9.1
2023-06-27T09:45:24.536Z | +-- @cspotcode/source-map-support@0.8.1
2023-06-27T09:45:24.539Z | | `-- @jridgewell/trace-mapping@0.3.9
2023-06-27T09:45:24.541Z | | +-- @jridgewell/resolve-uri@3.1.1
2023-06-27T09:45:24.544Z | | `-- @jridgewell/sourcemap-codec@1.4.15
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/node10@1.0.9
2023-06-27T09:45:24.555Z | +-- @tsconfig/node12@1.0.11
2023-06-27T09:45:24.558Z | +-- @tsconfig/node14@1.0.3
2023-06-27T09:45:24.560Z | +-- @tsconfig/node16@1.0.4
2023-06-27T09:45:24.563Z | +-- @types/node@20.3.0 deduped
2023-06-27T09:45:24.565Z | +-- acorn-walk@8.2.0
2023-06-27T09:45:24.568Z | +-- acorn@8.8.2
2023-06-27T09:45:24.570Z | +-- arg@4.1.3
2023-06-27T09:45:24.573Z | +-- create-require@1.1.1
2023-06-27T09:45:24.576Z | +-- diff@4.0.2
2023-06-27T09:45:24.579Z | +-- make-error@1.3.6
2023-06-27T09:45:24.582Z | +-- typescript@4.9.5 deduped
2023-06-27T09:45:24.584Z | +-- v8-compile-cache-lib@3.0.1
2023-06-27T09:45:24.587Z | `-- yn@3.1.1
2023-06-27T09:45:24.920Z +-- typescript@4.9.5
2023-06-27T09:45:24.532Z +-- ts-node@10.9.1
2023-06-27T09:45:24.536Z | +-- @cspotcode/source-map-support@0.8.1
2023-06-27T09:45:24.539Z | | `-- @jridgewell/trace-mapping@0.3.9
2023-06-27T09:45:24.541Z | | +-- @jridgewell/resolve-uri@3.1.1
2023-06-27T09:45:24.544Z | | `-- @jridgewell/sourcemap-codec@1.4.15
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/node10@1.0.9
2023-06-27T09:45:24.555Z | +-- @tsconfig/node12@1.0.11
2023-06-27T09:45:24.558Z | +-- @tsconfig/node14@1.0.3
2023-06-27T09:45:24.560Z | +-- @tsconfig/node16@1.0.4
2023-06-27T09:45:24.563Z | +-- @types/node@20.3.0 deduped
2023-06-27T09:45:24.565Z | +-- acorn-walk@8.2.0
2023-06-27T09:45:24.568Z | +-- acorn@8.8.2
2023-06-27T09:45:24.570Z | +-- arg@4.1.3
2023-06-27T09:45:24.573Z | +-- create-require@1.1.1
2023-06-27T09:45:24.576Z | +-- diff@4.0.2
2023-06-27T09:45:24.579Z | +-- make-error@1.3.6
2023-06-27T09:45:24.582Z | +-- typescript@4.9.5 deduped
2023-06-27T09:45:24.584Z | +-- v8-compile-cache-lib@3.0.1
2023-06-27T09:45:24.587Z | `-- yn@3.1.1
2023-06-27T09:45:24.920Z +-- typescript@4.9.5
--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.