R
Railway13mo ago
mgrabina

Dependencies Install failing for yarn + prisma/client

Hey there! This is what I am getting in deployment logs (file attached). config: ╔════════════════════ Nixpacks v1.19.0 ═══════════════════╗ ║ setup │ nodejs_21, yarn-1_x, openssl ║ ║─────────────────────────────────────────────────────────║ ║ install │ npm install -g corepack && corepack enable ║ ║ │ yarn install --frozen-lockfile ║ ║─────────────────────────────────────────────────────────║ ║ build │ yarn build ║ ║─────────────────────────────────────────────────────────║ ║ start │ yarn start ║ ╚═════════════════════════════════════════════════════════╝ package.json: { "packageManager": "[email protected]", "scripts": { "..." }, "dependencies": { "@prisma/client": "4.9.0", "..." }, "devDependencies": { "prisma": "4.9.0", "...", }, "prisma": { "seed": "ts-node ./prisma/seed.ts" }, "engines": { "node": ">=18.17.1" } } (this is a monorepo, and I added a specific yarn.lock in the folder of the package.json) Any ideas? Honestly I don't know what else to try since it is a pretty standard set up 😢 Thanks in advance!!!
48 Replies
Percy
Percy13mo ago
Project ID: N/A
mgrabina
mgrabinaOP13mo ago
5e850af2-d74a-4973-a849-a0107b7a93d4
Brody
Brody13mo ago
in your package.json set engines.node to just 18
mgrabina
mgrabinaOP13mo ago
Brody
Brody13mo ago
looks good
mgrabina
mgrabinaOP13mo ago
node = 18, same error
[stage-0 7/11] RUN --mount=type=cache,id=s/d5b56c84-15ed-47e1-80c8-fac8c9f9fea6-/usr/local/share/cache/yarn/v6,target=/usr/local/share/.cache/yarn/v6 yarn install --frozen-lockfile:
63.02 ➤ YN0000: │ @prisma/client@npm:4.9.0 [00c3b] STDERR at new NodeError (node:internal/errors:405:5) 63.02 ➤ YN0000: │ @prisma/client@npm:4.9.0 [00c3b] STDERR at ESMLoader.resolve (node:internal/modules/esm/loader:843:13) 63.02 ➤ YN0000: │ @prisma/client@npm:4.9.0 [00c3b] STDERR at async ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:7) { 63.02 ➤ YN0000: │ @prisma/client@npm:4.9.0 [00c3b] STDERR code: 'ERR_LOADER_CHAIN_INCOMPLETE' 63.02 ➤ YN0000: │ @prisma/client@npm:4.9.0 [00c3b] STDERR } 63.02 ➤ YN0000: │ @prisma/client@npm:4.9.0 [00c3b] STDERR 63.02 ➤ YN0000: │ @prisma/client@npm:4.9.0 [00c3b] STDERR Node.js v18.18.2 63.03 ➤ YN0009: │ @prisma/client@npm:4.9.0 [00c3b] couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-ba6c3355/build.log) 63.03 ➤ YN0000: └ Completed in 4s 365ms 63.05 ➤ YN0000: Failed with errors in 59s 357ms
Brody
Brody13mo ago
build logs again please
mgrabina
mgrabinaOP13mo ago
yarn version may be the problem?
mgrabina
mgrabinaOP13mo ago
in my local same code works as expected so maybe something related to environment tools vversions? e.g. yarn?
Brody
Brody13mo ago
what version of yarn do you use locally?
mgrabina
mgrabinaOP13mo ago
➜ backend git:(release) yarn -v 3.2.1
Brody
Brody13mo ago
use yarn 1 locally, and regen your lock file with yarn 1
mgrabina
mgrabinaOP13mo ago
i've set "packageManager": "[email protected]",
Brody
Brody13mo ago
i know, but please try what i suggested
mgrabina
mgrabinaOP13mo ago
one sec can .yarn with cache files and yarn releases help?
Brody
Brody13mo ago
i was looking to see if a yarn lock file made with yarn 1 would work, have you tested this?
mgrabina
mgrabinaOP13mo ago
on it having troubles with yarn versions is yarn 2 supported/ ?
Brody
Brody13mo ago
lets just test a lock file done with yarn 1 for now please
mgrabina
mgrabinaOP13mo ago
yeah trying but breaking a lot other stuff
Brody
Brody13mo ago
no worries
mgrabina
mgrabinaOP13mo ago
that's why I ask, maybe yarn 2 is easier to try
Brody
Brody13mo ago
i think it would be best to use yarn 1 locally
mgrabina
mgrabinaOP13mo ago
meanwhile quick question, railway savves already downloaded dependencies in cache somewhere to avoid re-downloading and log times of delpoyment?
Brody
Brody13mo ago
yes they do have caching
mgrabina
mgrabinaOP13mo ago
okay, so, the thing is that I have a monorepo with multiple packages, this is one of them. using yarn v1, I have a root yarn.lock.and because I dont have a yarn.lock in this package, it is trying to use npm ci ║ install │ npm install -g corepack && corepack enable ║ ║ │ npm ci
Brody
Brody13mo ago
shared monrorepo or isolated monorepo?
mgrabina
mgrabinaOP13mo ago
shared i think, why
Brody
Brody13mo ago
are you using turbo or nx?
mgrabina
mgrabinaOP13mo ago
none
Brody
Brody13mo ago
whats your root directory set to in the service settings
mgrabina
mgrabinaOP13mo ago
/packages/backend
Brody
Brody13mo ago
for a shared monorepo you want to leave the root directory at / then have specific build and start scripts to just build and just start the backend
mgrabina
mgrabinaOP13mo ago
it worked!! thank you very much
Brody
Brody13mo ago
no prob 🙂
mgrabina
mgrabinaOP13mo ago
last one, any ideas on how to optimize and don't use root directory?
Brody
Brody13mo ago
that's the standard for shared monorepos, perhaps you are asking how to stop either services from building when you make changes in either service?
mgrabina
mgrabinaOP13mo ago
oh no, I mean, it would be great if I can isolate and have only this package (optimizes size, loading time etc). My packages does not use anything from others, but the limitation here remember is that I can't have a local yarn.lock (so it will know and run yarn instead of npm ci) using yarn 1
Brody
Brody13mo ago
pretty sure the npm check is done before the yarn check, you should be able to have a package lock and a yarn lock and have railway default to npm ci, though I haven't tested this nope I was wrong, just looked at the package detection logic, npm is the default but if any other lock file is found it will default to that package manager instead though you can just overwrite the default install command with a nixpacks.toml file
[phases.install]
cmds = ['npm ci']
[phases.install]
cmds = ['npm ci']
this should run npm ci regardless of your detected package manager since you corrected yourself and said this isn't a shared monorepo, you could go back to setting the root directory and then just overwrite the install command like shown above (the nixpacks.toml file needs to be in the same folder as whatever the root directory is set to)
mgrabina
mgrabinaOP13mo ago
brody, are u there? I found this example using yarn 3.2.4
mgrabina
mgrabinaOP13mo ago
GitHub
nixpacks/examples/node-yarn-berry/package.json at 61f497b7a25de3fc9...
App source + Nix packages + Docker = Image. Contribute to railwayapp/nixpacks development by creating an account on GitHub.
mgrabina
mgrabinaOP13mo ago
So: - set root to /package/backend - set .yarnrc.yml: yarnPath: .yarn/releases/yarn-3.2.4.cjs - set packageManager in each package.json - set the yarn release file in .yarn/releases -even added the nixpacks.tml = [phases.install] cmds = ["yarn install --omit-dev"] still does not recognize the version of yarn to run. I need to use other than yarn 1 ╔═════════════ Nixpacks v1.19.0 ════════════╗ ║ setup │ nodejs_18, yarn-1_x, openssl ║ ║───────────────────────────────────────────║ ║ install │ yarn install --omit-dev ║ ║───────────────────────────────────────────║ ║ build │ yarn build-backend ║ ║───────────────────────────────────────────║ ║ start │ yarn start-backend ║ ╚═══════════════════════════════════════════╝
mgrabina
mgrabinaOP13mo ago
GitHub
nixpacks/src/providers/node/mod.rs at 61f497b7a25de3fc9da20e695569d...
App source + Nix packages + Docker = Image. Contribute to railwayapp/nixpacks development by creating an account on GitHub.
Brody
Brody13mo ago
it would significantly help if you could share your repo
mgrabina
mgrabinaOP13mo ago
managed to make it work, by reading the code of nixpacks. basically I provided it all (.yarn/release, .yarnrc.yml and a basic .toml choosing the install command) Now I am using the latest yarn version and running from the root. Thank you so much for all your help.
Brody
Brody13mo ago
awsome, happy you found a solution!
Want results from more Discord servers?
Add your server