R
Railwayβ€’13mo ago
antwan

Turborepo deploy getting TSC: Not Found

Trying to deploy the API package in my shared turborepo. Project ID: 479b4418-bb9f-403c-a4f1-5c24cd09b7ea The deployment is failing because tsc: not found. Similar to https://discord.com/channels/713503345364697088/1052194289985273966/1052194289985273966
93 Replies
Percy
Percyβ€’13mo ago
Project ID: N/A
Brody
Brodyβ€’13mo ago
okay now show me your package.json please
antwan
antwanβ€’13mo ago
root or child-package ?
Brody
Brodyβ€’13mo ago
the entire file please
antwan
antwanβ€’13mo ago
There are multiple package.json's One for each package, and one in the monorepo's root. Which would you like me to share, the service or the root package json
Brody
Brodyβ€’13mo ago
the package.json for the service that's giving you troubles
antwan
antwanβ€’13mo ago
Brody
Brodyβ€’13mo ago
I don't see tsc listed in the dependencies list? I do see tsup though, maybe you where in the middle of switching over to tsup? (I've heard tsup is better than tsc)
antwan
antwanβ€’13mo ago
so we have typescript in our root package dependencies. i just added it to the dependencies of this service/package, but still getting the same error below
antwan
antwanβ€’13mo ago
in fact, we use them both πŸ€¦β€β™‚οΈ
antwan
antwanβ€’13mo ago
Brody
Brodyβ€’13mo ago
that's not the full build logs, for future reference, to send full log files you'd want to create a .txt file and copy all log lines into that file
antwan
antwanβ€’13mo ago
hm yea the log-text highlight seems to get truncated when it's long
Brody
Brodyβ€’13mo ago
send the updated package.json?
antwan
antwanβ€’13mo ago
antwan
antwanβ€’13mo ago
just added tsc as it's own dependency to see if it resolves
Brody
Brodyβ€’13mo ago
hmmm I still don't see tsc in the dependencies? oh it gets installed with typescript
antwan
antwanβ€’13mo ago
npm
tsc
A deprecated release of the TypeScript compiler. Latest version: 2.0.4, last published: a year ago. Start using tsc in your project by running npm i tsc. There are 490 other projects in the npm registry using tsc.
Brody
Brodyβ€’13mo ago
my bad
antwan
antwanβ€’13mo ago
right anyway to install typescript globally? through nixPkgs or so?
Brody
Brodyβ€’13mo ago
should you need to though? doesn't npm prefix the scripts with npx so that you could run tsc from the install in node_modules?
antwan
antwanβ€’13mo ago
uh im not convinced it does actually
Brody
Brodyβ€’13mo ago
prefix it yourself?
antwan
antwanβ€’13mo ago
i did previously though i think because it isn't installing something is off, let me get you those error logs
Brody
Brodyβ€’13mo ago
maybe this might work?
npx --package typescript tsc --noEmit && tsup
npx --package typescript tsc --noEmit && tsup
antwan
antwanβ€’13mo ago
trying
#13 1.500
ο»Ώ#13 1.500 > @biteinc/maitred@0.0.1 compile:bundle
ο»Ώ#13 1.500 > npx tsc --noEmit && tsup
ο»Ώ#13 1.500
ο»Ώ
ο»Ώ#13 1.963 npm WARN config production Use `--omit=dev` instead.
ο»Ώ
ο»Ώ#13 2.523 npm ERR! code ENOENT
ο»Ώ#13 2.523 npm ERR! syscall lstat
ο»Ώ#13 2.524 npm ERR! path /app/packages/maitred/lib
ο»Ώ#13 2.525 npm ERR! errno -2
ο»Ώ#13 2.526 npm ERR! enoent ENOENT: no such file or directory, lstat '/app/packages/maitred/lib'
ο»Ώ#13 2.526 npm ERR! enoent This is related to npm not being able to find a file.
#13 1.500
ο»Ώ#13 1.500 > @biteinc/maitred@0.0.1 compile:bundle
ο»Ώ#13 1.500 > npx tsc --noEmit && tsup
ο»Ώ#13 1.500
ο»Ώ
ο»Ώ#13 1.963 npm WARN config production Use `--omit=dev` instead.
ο»Ώ
ο»Ώ#13 2.523 npm ERR! code ENOENT
ο»Ώ#13 2.523 npm ERR! syscall lstat
ο»Ώ#13 2.524 npm ERR! path /app/packages/maitred/lib
ο»Ώ#13 2.525 npm ERR! errno -2
ο»Ώ#13 2.526 npm ERR! enoent ENOENT: no such file or directory, lstat '/app/packages/maitred/lib'
ο»Ώ#13 2.526 npm ERR! enoent This is related to npm not being able to find a file.
^^ the error message when i ran npx without pointing to ts package like you suggested
Brody
Brodyβ€’13mo ago
now try with it pointing to the package
antwan
antwanβ€’13mo ago
also @Brody im noticing that even though I've added my engines definitions in the package lock, it's not respecting them

ο»Ώ#11 3.963 npm WARN EBADENGINE
ο»ΏUnsupported engine {
ο»Ώ#11 3.963 npm WARN EBADENGINE package: 'root@1.30.16',
ο»Ώ#11 3.963 npm WARN EBADENGINE required: { node: '18.16.0', npm: '9.7.2' },
ο»Ώ#11 3.964 npm WARN EBADENGINE current: { node: 'v18.12.1', npm: '8.19.2' }
ο»Ώ#11 3.964 npm WARN EBADENGINE }
ο»Ώ#11 3.994 npm WARN EBADENGINE Unsupported engine {
ο»Ώ
ο»Ώ#11 3.994 npm WARN EBADENGINE package: '@biteinc/maitred@0.0.1',
ο»Ώ#11 3.994 npm WARN EBADENGINE required: { node: '18.16.0', npm: '9.7.2' },
ο»Ώ#11 3.994 npm WARN EBADENGINE current: { node: 'v18.12.1', npm: '8.19.2' }
ο»Ώ#11 3.994 npm WARN EBADENGINE }
ο»Ώ

ο»Ώ#11 3.963 npm WARN EBADENGINE
ο»ΏUnsupported engine {
ο»Ώ#11 3.963 npm WARN EBADENGINE package: 'root@1.30.16',
ο»Ώ#11 3.963 npm WARN EBADENGINE required: { node: '18.16.0', npm: '9.7.2' },
ο»Ώ#11 3.964 npm WARN EBADENGINE current: { node: 'v18.12.1', npm: '8.19.2' }
ο»Ώ#11 3.964 npm WARN EBADENGINE }
ο»Ώ#11 3.994 npm WARN EBADENGINE Unsupported engine {
ο»Ώ
ο»Ώ#11 3.994 npm WARN EBADENGINE package: '@biteinc/maitred@0.0.1',
ο»Ώ#11 3.994 npm WARN EBADENGINE required: { node: '18.16.0', npm: '9.7.2' },
ο»Ώ#11 3.994 npm WARN EBADENGINE current: { node: 'v18.12.1', npm: '8.19.2' }
ο»Ώ#11 3.994 npm WARN EBADENGINE }
ο»Ώ
Brody
Brodyβ€’13mo ago
yes, you can only specify major versions
antwan
antwanβ€’13mo ago
noted.
antwan
antwanβ€’13mo ago
okay @Brody
antwan
antwanβ€’13mo ago
seems to fail to install typescript in the first place let me bump the version listed
Brody
Brodyβ€’13mo ago
everything always has to be so difficult with typescript and just a friendly reminder, theres no need for pings - #πŸ›‚ο½œreadme #5
antwan
antwanβ€’13mo ago
apologies brotha
Brody
Brodyβ€’13mo ago
any success? i can just give you something that will install ts globally for the shotgun approach
antwan
antwanβ€’13mo ago
let's do it no luck
Brody
Brodyβ€’13mo ago
give me your current railway.json please
antwan
antwanβ€’13mo ago
empty where do i export it from
Brody
Brodyβ€’13mo ago
the details tab
antwan
antwanβ€’13mo ago
sorry, the details tab under which screen? maybe i don't have one yet since there's no successful deploy?
Brody
Brodyβ€’13mo ago
Brody
Brodyβ€’13mo ago
failed should still have it
antwan
antwanβ€’13mo ago
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "npm run compile --prefix packages/maitred"
},
"deploy": {
"numReplicas": 1,
"startCommand": "npm run start --prefix packages/maitred",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "npm run compile --prefix packages/maitred"
},
"deploy": {
"numReplicas": 1,
"startCommand": "npm run start --prefix packages/maitred",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
found it
Brody
Brodyβ€’13mo ago
did you say this was a monorepo, or a turborepo
antwan
antwanβ€’13mo ago
we use turbo to compile
Brody
Brodyβ€’13mo ago
then railway would only be installing the deps in your root's package.json
antwan
antwanβ€’13mo ago
damn
Brody
Brodyβ€’13mo ago
since by default railway uses the root directory, and thus its using the package.json in the root directory
antwan
antwanβ€’13mo ago
i imagine there's some voodoo causing it to have issues, though my root package.json does have typescript in the devdependencies
Brody
Brodyβ€’13mo ago
NODE_ENV would be set to production when on railway, so npm ci wouldnt install typescript
antwan
antwanβ€’13mo ago
so if we were using lerna or some monorepo type to compile we'd be okay? is there any suggestion that doesn't involve regressing to lerna?
Brody
Brodyβ€’13mo ago
okay so lets say i just cloned your repo, starting from the root directory what would be the commands i would run to get this app fully operational
antwan
antwanβ€’13mo ago
after installing the external dependencies like mongo, node etc. simply npm i npm run compile npm run dev nothing fancy from the root
Brody
Brodyβ€’13mo ago
seems too simple to work
antwan
antwanβ€’13mo ago
i wouldn't lie to you turbo handles the build for all the separate packages
Brody
Brodyβ€’13mo ago
how is npm i in the root directory installing deps from a package.json in a sub dir
antwan
antwanβ€’13mo ago
the workspaces in the package.json i believe
Brody
Brodyβ€’13mo ago
can i take a look at your repo?
antwan
antwanβ€’13mo ago
unfortunately im not authorized to give you access but the structure is something like package.json packages |- package a |- - package.json |- package b |- - package.json ... Contents for the root package.json here and the previous examples are one of (namely, maitred) these packages
Brody
Brodyβ€’13mo ago
wait this thread says monorepo, is it a mono or turbo?
antwan
antwanβ€’13mo ago
100% turbo sorry we use those interchangeably appreciate ya i did have it in the description
Brody
Brodyβ€’13mo ago
and how many sub packages are there
antwan
antwanβ€’13mo ago
a tonne lol say around 15-20 in fact it's more
Brody
Brodyβ€’13mo ago
πŸ™€
antwan
antwanβ€’13mo ago
it's why we use turbo otherwise it'd be unbearable hence why I'd call it a regression
Brody
Brodyβ€’13mo ago
you also did get bad engine errors?
Brody
Brodyβ€’13mo ago
well im really sorry but my knowledge on the subject has ran out 😦
angelo
angeloβ€’13mo ago
cc @aleks
root
rootβ€’13mo ago
Could you send your Dockerfile?
angelo
angeloβ€’13mo ago
No dockerfile, this is with Nixpacks
root
rootβ€’13mo ago
oh nevermind I was looking at the wrong thing, sorry hmm
antwan
antwanβ€’13mo ago
@aleks the service package.json and the root package.json
angelo
angeloβ€’13mo ago
The good news here is that the Node engine issue is gone But just can't find TSC x_x
root
rootβ€’13mo ago
Could you send the Nixpacks plan table? (at the top of the build logs)
angelo
angeloβ€’13mo ago
I got you
╔═══════════════════════════════ Nixpacks v1.9.2 ══════════════════════════════╗
ο»Ώβ•‘ setup β”‚ nodejs-18_x, npm-8_x, libnss3, libatk1.0-0, libatk-bridge2.0-0, β•‘
ο»Ώβ•‘ β”‚ libcups2, libgbm1, libasound2, libpangocairo-1.0-0, libxss1, β•‘
ο»Ώβ•‘ β”‚ libgtk-3-0, libxshmfence1, libglu1 β•‘
║──────────────────────────────────────────────────────────────────────────────║
ο»Ώβ•‘ install β”‚ npm ci β•‘
║──────────────────────────────────────────────────────────────────────────────║
ο»Ώβ•‘ build β”‚ npm run compile --prefix packages/maitred β•‘
║──────────────────────────────────────────────────────────────────────────────║
ο»Ώβ•‘ start β”‚ npm run start --prefix packages/maitred β•‘
ο»Ώβ•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
╔═══════════════════════════════ Nixpacks v1.9.2 ══════════════════════════════╗
ο»Ώβ•‘ setup β”‚ nodejs-18_x, npm-8_x, libnss3, libatk1.0-0, libatk-bridge2.0-0, β•‘
ο»Ώβ•‘ β”‚ libcups2, libgbm1, libasound2, libpangocairo-1.0-0, libxss1, β•‘
ο»Ώβ•‘ β”‚ libgtk-3-0, libxshmfence1, libglu1 β•‘
║──────────────────────────────────────────────────────────────────────────────║
ο»Ώβ•‘ install β”‚ npm ci β•‘
║──────────────────────────────────────────────────────────────────────────────║
ο»Ώβ•‘ build β”‚ npm run compile --prefix packages/maitred β•‘
║──────────────────────────────────────────────────────────────────────────────║
ο»Ώβ•‘ start β”‚ npm run start --prefix packages/maitred β•‘
ο»Ώβ•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
root
rootβ€’13mo ago
try removing the --prefix from the build command?
antwan
antwanβ€’13mo ago
okay but then it'd just build the whole project no?
root
rootβ€’13mo ago
I guess so, never mind then hmm oh try npx turbo maitred:compile instead
antwan
antwanβ€’13mo ago
okay trying
root
rootβ€’13mo ago
And then the start command should be able to be left at the Railway default, since it'll look for a start script by default - just set NIXPACKS_TURBO_APP_NAME to maitred in your environment variables. Could you rename your compile script to build? That'll allow the default options to work.
antwan
antwanβ€’13mo ago
i thought turbo targets the package differently --scope not familiar with the maitred:compile command
root
rootβ€’13mo ago
If you can rename your compile script to build, you can remove all custom configuration
antwan
antwanβ€’13mo ago
ok
root
rootβ€’13mo ago
it should be <package name>:<script>, also - I just checked the Nixpacks codebase (unless it's changed since that was written)
angelo
angeloβ€’13mo ago
Yea, its calling that correctly
antwan
antwanβ€’13mo ago
so npx turbo compile package-name:script can't find any tasks --scope does target the package it may be outdated syntax
root
rootβ€’13mo ago
sorry, I was unclear npx turbo maitred:compile
angelo
angeloβ€’13mo ago
I think that got deprecated They now want you to use: https://turbo.build/repo/docs/core-concepts/monorepos/filtering
root
rootβ€’13mo ago
I stand corrected, sorry
jr
jrβ€’12mo ago
Is this still an issue? I believe the problem is that there are a bunch of "cacheDirectories" in the package.json file. Removing that should work It is not recommended to cache node_modules directories directly. Especially in Nixpacks since those folders will not be available in the final image and they contain runtime dependencies
antwan
antwanβ€’12mo ago
it was the cacheDirectories it seems - got the service up and running πŸ₯‚ appreciate the support