R
Railwayβ€’2y 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β€’2y ago
Project ID: N/A
Brody
Brodyβ€’2y ago
okay now show me your package.json please
antwan
antwanOPβ€’2y ago
root or child-package ?
Brody
Brodyβ€’2y ago
the entire file please
antwan
antwanOPβ€’2y 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β€’2y ago
the package.json for the service that's giving you troubles
antwan
antwanOPβ€’2y ago
Brody
Brodyβ€’2y 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
antwanOPβ€’2y 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
antwanOPβ€’2y ago
in fact, we use them both πŸ€¦β€β™‚οΈ
antwan
antwanOPβ€’2y ago
Brody
Brodyβ€’2y 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
antwanOPβ€’2y ago
hm yea the log-text highlight seems to get truncated when it's long
Brody
Brodyβ€’2y ago
send the updated package.json?
antwan
antwanOPβ€’2y ago
antwan
antwanOPβ€’2y ago
just added tsc as it's own dependency to see if it resolves
Brody
Brodyβ€’2y ago
hmmm I still don't see tsc in the dependencies? oh it gets installed with typescript
antwan
antwanOPβ€’2y 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β€’2y ago
my bad
antwan
antwanOPβ€’2y ago
right anyway to install typescript globally? through nixPkgs or so?
Brody
Brodyβ€’2y 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
antwanOPβ€’2y ago
uh im not convinced it does actually
Brody
Brodyβ€’2y ago
prefix it yourself?
antwan
antwanOPβ€’2y ago
i did previously though i think because it isn't installing something is off, let me get you those error logs
Brody
Brodyβ€’2y ago
maybe this might work?
npx --package typescript tsc --noEmit && tsup
npx --package typescript tsc --noEmit && tsup
antwan
antwanOPβ€’2y ago
trying
#13 1.500
ο»Ώ#13 1.500 > @biteinc/[email protected] 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/[email protected] 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β€’2y ago
now try with it pointing to the package
antwan
antwanOPβ€’2y 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: '[email protected]',
ο»Ώ#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/[email protected]',
ο»Ώ#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: '[email protected]',
ο»Ώ#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/[email protected]',
ο»Ώ#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β€’2y ago
yes, you can only specify major versions
antwan
antwanOPβ€’2y ago
noted.
antwan
antwanOPβ€’2y ago
okay @Brody
antwan
antwanOPβ€’2y ago
seems to fail to install typescript in the first place let me bump the version listed
Brody
Brodyβ€’2y ago
everything always has to be so difficult with typescript and just a friendly reminder, theres no need for pings - #πŸ›‚ο½œreadme #5
antwan
antwanOPβ€’2y ago
apologies brotha
Brody
Brodyβ€’2y ago
any success? i can just give you something that will install ts globally for the shotgun approach
antwan
antwanOPβ€’2y ago
let's do it no luck
Brody
Brodyβ€’2y ago
give me your current railway.json please
antwan
antwanOPβ€’2y ago
empty where do i export it from
Brody
Brodyβ€’2y ago
the details tab
antwan
antwanOPβ€’2y ago
sorry, the details tab under which screen? maybe i don't have one yet since there's no successful deploy?
Brody
Brodyβ€’2y ago
Brody
Brodyβ€’2y ago
failed should still have it
antwan
antwanOPβ€’2y 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β€’2y ago
did you say this was a monorepo, or a turborepo
antwan
antwanOPβ€’2y ago
we use turbo to compile
Brody
Brodyβ€’2y ago
then railway would only be installing the deps in your root's package.json
antwan
antwanOPβ€’2y ago
damn
Brody
Brodyβ€’2y ago
since by default railway uses the root directory, and thus its using the package.json in the root directory
antwan
antwanOPβ€’2y 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β€’2y ago
NODE_ENV would be set to production when on railway, so npm ci wouldnt install typescript
antwan
antwanOPβ€’2y 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β€’2y 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
antwanOPβ€’2y 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β€’2y ago
seems too simple to work
antwan
antwanOPβ€’2y ago
i wouldn't lie to you turbo handles the build for all the separate packages
Brody
Brodyβ€’2y ago
how is npm i in the root directory installing deps from a package.json in a sub dir
antwan
antwanOPβ€’2y ago
the workspaces in the package.json i believe
Brody
Brodyβ€’2y ago
can i take a look at your repo?
antwan
antwanOPβ€’2y 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β€’2y ago
wait this thread says monorepo, is it a mono or turbo?
antwan
antwanOPβ€’2y ago
100% turbo sorry we use those interchangeably appreciate ya i did have it in the description
Brody
Brodyβ€’2y ago
and how many sub packages are there
antwan
antwanOPβ€’2y ago
a tonne lol say around 15-20 in fact it's more
Brody
Brodyβ€’2y ago
πŸ™€
antwan
antwanOPβ€’2y ago
it's why we use turbo otherwise it'd be unbearable hence why I'd call it a regression
Brody
Brodyβ€’2y ago
you also did get bad engine errors?
Brody
Brodyβ€’2y ago
well im really sorry but my knowledge on the subject has ran out 😦
angelo
angeloβ€’17mo ago
cc @aleks
root
rootβ€’17mo ago
Could you send your Dockerfile?
angelo
angeloβ€’17mo ago
No dockerfile, this is with Nixpacks
root
rootβ€’17mo ago
oh nevermind I was looking at the wrong thing, sorry hmm
antwan
antwanOPβ€’17mo ago
@aleks the service package.json and the root package.json
angelo
angeloβ€’17mo ago
The good news here is that the Node engine issue is gone But just can't find TSC x_x
root
rootβ€’17mo ago
Could you send the Nixpacks plan table? (at the top of the build logs)
angelo
angeloβ€’17mo 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β€’17mo ago
try removing the --prefix from the build command?
antwan
antwanOPβ€’17mo ago
okay but then it'd just build the whole project no?
root
rootβ€’17mo ago
I guess so, never mind then hmm oh try npx turbo maitred:compile instead
antwan
antwanOPβ€’17mo ago
okay trying
root
rootβ€’17mo 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
antwanOPβ€’17mo ago
i thought turbo targets the package differently --scope not familiar with the maitred:compile command
root
rootβ€’17mo ago
If you can rename your compile script to build, you can remove all custom configuration
antwan
antwanOPβ€’17mo ago
ok
root
rootβ€’17mo ago
it should be <package name>:<script>, also - I just checked the Nixpacks codebase (unless it's changed since that was written)
angelo
angeloβ€’17mo ago
Yea, its calling that correctly
antwan
antwanOPβ€’17mo 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β€’17mo ago
sorry, I was unclear npx turbo maitred:compile
angelo
angeloβ€’17mo ago
I think that got deprecated They now want you to use: https://turbo.build/repo/docs/core-concepts/monorepos/filtering
root
rootβ€’17mo ago
I stand corrected, sorry
jr
jrβ€’17mo 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
antwanOPβ€’17mo ago
it was the cacheDirectories it seems - got the service up and running πŸ₯‚ appreciate the support
Want results from more Discord servers?
Add your server