Need help configuring nickspacks
Hi, I want the following to happen,
npm install
npm run build
npm run init
npm run start
This is my nickspacks file:
But when I deploy, the nickspacks plan looks like this:
╔═════════ Nixpacks v1.29.0 ══════════╗
║ setup │ nodejs_22, yarn-1_x ║
║─────────────────────────────────────║
║ start │ npm run init ║
║ │ npm run start ║
║─────────────────────────────────────║
║ install │ npm install -g corepack ║
║ │ corepack enable ║
║ │ corepack prepare [email protected] --activate║
║ │ npm install ║
║──────────────────────────────────────║
║ build │ npm run build ║
║──────────────────────────────────────║
║ start │ yarn run start ║
╚═══════════════════════════════╝
I have not set a custom start command
- why does it put my start commands before install?
- where does the last yarn command come from?
Because of the order of things my project doesn build correctly, so how can I get the order right?
Solution:Jump to solution
thats all you need, nixpacks will run
npm ci
and npm build
in the correct order by default...20 Replies
Project ID:
c13d3629-3ab7-4743-994f-b90b613ce66e
c13d3629-3ab7-4743-994f-b90b613ce66e
did you use AI to generate that nixpacks.toml file?
Yes, partially. But i tried like 10 different formats now, none of which gave me the desired results.
yeah you have some syntax wrong, and have left some syntax out
why
npm install
instead of npm ci
?I have used this part for ages, and it works well.
But I want to add custom build and start command to the nixpacks file (if possible).
What does
npm ci
do ?installs packages from the lock file
Oh. I thought it already did that 🤔😬
does node 22 not come with npm 10? is there any reason you are installing npm with corepack?
I will try without it, but i recall resolving some error with this... but thats long ago, and a lot have changed since, so my config might be outdated in that regard.
Anyway, my editor doesn't know nickspacks syntax, can't highlight whats wrong.
is
cmd = "npm run x && npm run y"
better than cmds = []
?cmd is only valid syntax for the start phase
ill rewrite this for you, gimmie a few minutes
i assume this is the order you want?
That's right. And I assume the run init and run start must happen during the start phase - if that is important
if you want them to run during runtime sure
Solution
thats all you need, nixpacks will run
npm ci
and npm build
in the correct order by defaultAlright, so I delete evrything else? I think though, that it will pick node 18 then? and not 22 ?
the node version is picked up from
engines.node
in your package.jsonOK, should be good then for this project
Alright, this looks better! So, if I just delete yarn.lock it will default to npm ci ? 🙂
correct
Alright. Thanks Brody! Always appreciate your rapid help 🙂
no problem!