web-dev
September 10, 2024, 11:56pm
1
I am deploying my Node.js and keep getting this error Cannot find a tsconfig.json file at the specified directory: ‘./’
I definitely have the tsconfig.json file at root. When I run it locally, everything seems fine. I am not sure why it cannot find it at the root directory when it’s definitely there. What am I missing? This is logs when called fly deploy
=> ERROR [build 3/6] RUN npm ci --include=dev 7.0s
[build 3/6] RUN npm ci --include=dev:
6.163
6.163 > web-dev-project-node@1.0.0 postinstall
6.163 > npm run build
6.163
6.511
6.511 > web-dev-project-node@1.0.0 build
6.511 > tsc --project ./
6.511
6.718 error TS5057: Cannot find a tsconfig.json file at the specified directory: ‘./’.
6.735 npm notice
6.735 npm notice New minor version of npm available! 10.1.0 → 10.8.3
6.735 npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.3
6.735 npm notice Run npm install -g npm@10.8.3
to update!
6.735 npm notice
6.736 npm ERR! code 1
6.737 npm ERR! path /app
6.738 npm ERR! command failed
6.738 npm ERR! command sh -c npm run build
6.739
6.739 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-09-10T23_53_23_452Z-debug-0.log
Error: failed to fetch an image or build from source: error building: failed to solve: process “/bin/sh -c npm ci --include=dev” did not complete successfully: exit code: 1
khuezy
September 10, 2024, 11:58pm
2
Please share your Dockerfile
web-dev
September 11, 2024, 12:09am
6
Here is Dockerfile. Thank you!
ARG NODE_VERSION=20.8.1
FROM node:${NODE_VERSION}-slim as base
LABEL fly_launch_runtime=“Node.js”
WORKDIR /app
ENV NODE_ENV=“production”
FROM base as build
RUN apt-get update -qq &&
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3
COPY --link package-lock.json package.json ./
RUN npm ci --include=dev
COPY --link . .
RUN npm run build
RUN npm prune --omit=dev
FROM base
COPY --from=build /app /app
EXPOSE 3000
CMD [ “npm”, “run”, “start” ]
khuezy
September 11, 2024, 12:42am
7
Do you have a postinstall script that runs your tsc? Try moving the COPY --link . .
above your npm ci
web-dev
September 11, 2024, 12:53am
8
I do have the
postinstall: “npm run build”
in my package.json. after I removed the
COPY --link package-lock.json package.json
I got this error
ERROR [build 2/5] RUN npm ci --include=dev 0.7s
[build 2/5] RUN npm ci --include=dev:
0.644 npm ERR! code EUSAGE
0.647 npm ERR!
0.647 npm ERR! The npm ci
command can only install with an existing package-lock.json or
0.647 npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
0.648 npm ERR! later to generate a package-lock.json file, then try again.
0.648 npm ERR!
0.648 npm ERR! Clean install a project
0.648 npm ERR!
0.648 npm ERR! Usage:
0.648 npm ERR! Options:
0.648 npm ERR! [–install-strategy <hoisted|nested|shallow|linked>] [–legacy-bundling]
0.648 npm ERR! [–global-style] [–omit <dev|optional|peer> [–omit <dev|optional|peer> …]]
0.648 npm ERR! [–strict-peer-deps] [–foreground-scripts] [–ignore-scripts] [–no-audit]
0.648 npm ERR! [–no-bin-links] [–no-fund] [–dry-run]
0.648 npm ERR! [-w|–workspace [-w|–workspace …]]
0.648 npm ERR! [-ws|–workspaces] [–include-workspace-root] [–install-links]
0.648 npm ERR!
0.648 npm ERR! Options:
0.648 npm ERR! [–install-strategy <hoisted|nested|shallow|linked>] [–legacy-bundling]
0.648 npm ERR! [–global-style] [–omit <dev|optional|peer> [–omit <dev|optional|peer> …]]
0.648 npm ERR! [–strict-peer-deps] [–foreground-scripts] [–ignore-scripts] [–no-audit]
0.648 npm ERR! [–no-bin-links] [–no-fund] [–dry-run]
0.648 npm ERR! [-w|–workspace [-w|–workspace …]]
0.648 npm ERR! [-ws|–workspaces] [–include-workspace-root] [–install-links]
0.648 npm ERR! Options:
0.648 npm ERR! [–install-strategy <hoisted|nested|shallow|linked>] [–legacy-bundling]
0.648 npm ERR! [–global-style] [–omit <dev|optional|peer> [–omit <dev|optional|peer> …]]
0.648 npm ERR! [–strict-peer-deps] [–foreground-scripts] [–ignore-scripts] [–no-audit]
0.648 npm ERR! [–no-bin-links] [–no-fund] [–dry-run]
0.648 npm ERR! [-w|–workspace [-w|–workspace …]]
0.648 npm ERR! Options:
0.648 npm ERR! [–install-strategy <hoisted|nested|shallow|linked>] [–legacy-bundling]
0.648 npm ERR! [–global-style] [–omit <dev|optional|peer> [–omit <dev|optional|peer> …]]
0.648 npm ERR! [–strict-peer-deps] [–foreground-scripts] [–ignore-scripts] [–no-audit]
0.648 npm ERR! [–no-bin-links] [–no-fund] [–dry-run]
0.648 npm ERR! Options:
0.648 npm ERR! [–install-strategy <hoisted|nested|shallow|linked>] [–legacy-bundling]
0.648 npm ERR! [–global-style] [–omit <dev|optional|peer> [–omit <dev|optional|peer> …]]
0.648 npm ERR! [–strict-peer-deps] [–foreground-scripts] [–ignore-scripts] [–no-audit]
0.648 npm ERR! Options:
0.648 npm ERR! [–install-strategy <hoisted|nested|shallow|linked>] [–legacy-bundling]
0.648 npm ERR! [–global-style] [–omit <dev|optional|peer> [–omit <dev|optional|peer> …]]
0.648 npm ERR! Options:
0.648 npm ERR! [–install-strategy <hoisted|nested|shallow|linked>] [–legacy-bundling]
0.648 npm ERR! Options:
0.648 npm ERR! Options:
0.648 npm ERR! Options:
0.648 npm ERR! Options:
0.648 npm ERR! Options:
0.648 npm ERR! [–install-strategy <hoisted|nested|shallow|linked>] [–legacy-bundling]
0.648 npm ERR! [–global-style] [–omit <dev|optional|peer> [–omit <dev|optional|peer> …]]
0.648 npm ERR! [–strict-peer-deps] [–foreground-scripts] [–ignore-scripts] [–no-audit]
0.648 npm ERR! [–no-bin-links] [–no-fund] [–dry-run]
0.648 npm ERR! [-w|–workspace [-w|–workspace …]]
0.648 npm ERR! [-ws|–workspaces] [–include-workspace-root] [–install-links]
0.648 npm ERR!
0.648 npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
0.648 npm ERR!
0.648 npm ERR! Run “npm help ci” for more info
0.650
0.650 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-09-11T00_44_17_965Z-debug-0.log
khuezy
September 11, 2024, 12:59am
9
you don’t want to remove that, you need it b/c npm ci
requires a lock file.
COPY --link . . # Move me above the install so that the tsconfig.json exists
RUN npm ci --include=dev
web-dev
September 11, 2024, 1:02am
10
Ohhh I see. It works now! Thank you so much!!!
system
Closed
September 18, 2024, 1:02am
11
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.