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": "yarn@3.2.1", "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
Percy7mo ago
Project ID: N/A
mgrabina
mgrabina7mo ago
5e850af2-d74a-4973-a849-a0107b7a93d4
Brody
Brody7mo ago
in your package.json set engines.node to just 18
Brody
Brody7mo ago
looks good
mgrabina
mgrabina7mo 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
Brody7mo ago
build logs again please
mgrabina
mgrabina7mo ago
yarn version may be the problem?
mgrabina
mgrabina7mo ago
in my local same code works as expected so maybe something related to environment tools vversions? e.g. yarn?
Brody
Brody7mo ago
what version of yarn do you use locally?
mgrabina
mgrabina7mo ago
➜ backend git:(release) yarn -v 3.2.1
Brody
Brody7mo ago
use yarn 1 locally, and regen your lock file with yarn 1
mgrabina
mgrabina7mo ago
i've set "packageManager": "yarn@3.2.1",
Brody
Brody7mo ago
i know, but please try what i suggested
mgrabina
mgrabina7mo ago
one sec can .yarn with cache files and yarn releases help?
Brody
Brody7mo ago
i was looking to see if a yarn lock file made with yarn 1 would work, have you tested this?
mgrabina
mgrabina7mo ago
on it having troubles with yarn versions is yarn 2 supported/ ?
Brody
Brody7mo ago
lets just test a lock file done with yarn 1 for now please
mgrabina
mgrabina7mo ago
yeah trying but breaking a lot other stuff
Brody
Brody7mo ago
no worries
mgrabina
mgrabina7mo ago
that's why I ask, maybe yarn 2 is easier to try
Brody
Brody7mo ago
i think it would be best to use yarn 1 locally
mgrabina
mgrabina7mo ago
meanwhile quick question, railway savves already downloaded dependencies in cache somewhere to avoid re-downloading and log times of delpoyment?
Brody
Brody7mo ago
yes they do have caching
mgrabina
mgrabina7mo 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
Brody7mo ago
shared monrorepo or isolated monorepo?
mgrabina
mgrabina7mo ago
shared i think, why
Brody
Brody7mo ago
are you using turbo or nx?
mgrabina
mgrabina7mo ago
none
Brody
Brody7mo ago
whats your root directory set to in the service settings
mgrabina
mgrabina7mo ago
/packages/backend
Brody
Brody7mo 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
mgrabina7mo ago
it worked!! thank you very much
Brody
Brody7mo ago
no prob 🙂
mgrabina
mgrabina7mo ago
last one, any ideas on how to optimize and don't use root directory?
Brody
Brody7mo 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
mgrabina7mo 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
Brody7mo 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
mgrabina7mo ago
brody, are u there? I found this example using yarn 3.2.4
mgrabina
mgrabina7mo 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
mgrabina7mo 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
mgrabina7mo 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
Brody7mo ago
it would significantly help if you could share your repo
mgrabina
mgrabina7mo 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
Brody7mo ago
awsome, happy you found a solution!