Dajngo/Tailwind deployment Error: No start command could be found
Project id - 5b1ca7b8-37a6-491d-a6e1-2ca3e0236431
Hi, can someone help me with this error I am getting on build. Its a Django project which is dependant on Tailwind (via Django-Tailwind), I understand it needs Node to function but my pre-deployment research led me to believe that Django-Tailwind would compile the package.json and Nix would automatically install Node and any dependencies on Build (oh so easy right 🙂 ). Obviously this isn't the case.
What should I be looking to put into my package.json, which I assume needs a script/command ? I'm a Python/Django person so this is a mystery to me.
Any help much appreciated.
85 Replies
Project ID:
5b1ca7b8-37a6-491d-a6e1-2ca3e0236431
please share your repo
what is the services root directory set to?
Doh, / ---- should be /mysite I take it? let me try
yes but you are also using a Dockerfile, thus nixpacks is not involved at all, it would be up to you to write the dockerfile that builds your app properly
I'm not using Docker, I assumed would be ignored
Yea it's created automatically by Wagtail
and it would be used by railway
Ah right Ok, i'll remove it from repo
so to build this app of yours, you would need node and what node/npm commands do you need to run?
Django-Tailwind is reliant on Node in dev i do
python manage.py taliwind start
to build the css i do python manage.py tailwind build
. From their docs ..."This will replace the development build with a bundle optimized for production. No further actions are necessary; you can deploy"you would need to write a nixpacks.toml file to add node to your build, and to add extra phases that will run those commands you just spoke of.
https://nixpacks.com/docs/guides/configuring-builds
Ok thanks for pointing me in the right direction, the file would live in the root directory of the app?
it would live in the same directory you have the service set to
yea ok
Ok, looks like Django-Tailwind creates package.json when compiling for production
So I pointed
nixpacks.toml
points towards it...
[start]
cmd = 'npm start --prefix "theme/static_src"'
App builds but crashes and i'm seeing the error in Deploy logs.
sh: 1: cross-env: not found
npm WARN config production Use
--omit=dev instead.
what does nixpacks detect your app as? a python app or a node app?
Sorry i'm unsure on where find that out
setup │ nodejs_18, npm-9_x ║
install │ npm ci
start │ npm start --prefix "theme/static_src" ║
start │ npm start --prefix "theme/static_src" ║
thats exactly how you find out.
it says node there, but you have a python app (with node for tailwind).
so you need to overwrite the providers to just python in your nixpacks.toml.
then you want to add node back to the setup phase as a nix package.
then add the phases with the commands you need to run.
Right ok, i'm going to sleep on this and look have a go with a fresh brain in the morning, sorry for the questions JS/Node deployment all new to me
sounds good, give it another try tomorrow and if you cant figure it out i will write the nixpacks.toml file for you
Cheers dude much appreciated
cheers!
Yea slept on it, tried some things, still confused as anything! I have read that Django-Tailwind makes the need for Node on the server redundant, is there way for Railway to ignore any Node files on build? Edit....right i'll try pushing to my repo with just the Django and CSS created by Django-Tailwind and not any Node files etc etc
let's see what you currently have for your nixpacks.toml file
I've just left it at
package.json
the
...
means you are allowing the auto detected node provider, and then only adding python
you are also running dev commands that watch for changes, you definitely don't want to do that in a production environmentOk, yea i had no idea
and you are also missing the extra phases from your nixpacks.toml that run the tailwind commands you have talked about
Yea, i've had real trouble understading where and how to add them, i have tried 🙂
just curious, how many times would you say you've read the nixpacks page I linked?
Lots. From a a Django perpective I asked for advice and I'm not sure if this helps the situation but this is the advice i've received.
that's spot on, who gave you that advice
Reddit.
But if Node isn't required anymore, why does it need Node with NPM?
I'm not sure why you think node isn't required
tailwind is an npm package, so you'd need node/npm to download it
I'm unsure because this is the first time i've handled anything to do with Node so everything is new
did you know your Procfile has the wrong casing, not that it would solve your issue
also, please remove your
node_modules
folder from the repo and make sure its in your .gitignore fileOk, thanks for pointing that out will do
also also, prob shouldnt be commiting your database file to your repo
Yea i know, this problem has kinda overtook other things that need changing.
id recommend using postgres
I am
gotcha, going to try my hand at this nixpacks.toml file now
Ok, i'm just looking at other nixpacks files in other repos and relising how bad i am at this 🙂
heres an example of a nixpacks.toml file with different phases https://github.com/brody192/vite-react-template/blob/main/nixpacks.toml
instead of a nixpacks.toml file, i went with a railway.json file with embeded nixpacks config, so that i could have autocomplete, add this railway.json file to your project.
Error: No start command could be found -- shall I remove the nixpacks.toml file? I deleted it's contents assuming it needed to be empty
yes remove it
make sure its in your .gitignore file
node_modules removed, nixpacks.toml removed, pushed railway.toml but still get Error: No start command could be found
whats your root directory set to
ok building, forgot i started a new project, corrected root directory its building
argg faile don build
full logs please https://bookmarklets.up.railway.app/log-downloader/
quoting your build log here
Set the DB_USER environment variable
Yea just looking, set env's in Railway I gather? Progress at least thanks so much dude
yeah a service variable, make absolute sure you are using reference variables https://docs.railway.app/guides/variables#referencing-another-services-variable
Ok i need to eat and i'll update 🙂 legend
Ok, env's set and all ok....i know get this error when installing Djngo-Taiwind, i assume it related to NPM_BIN_PATH which in development is set to the local path. Not sure how to set this in development?
full build logs please
npm is installed just fine, as you can see the npm ci command finished just fine, this is an issue with django tailwind
but lets try giving it the path env it wants
that echo is just a debug and can be removed later
I’m afk for an hour I’ll give it a try then. Hopefully it work many thanks for sticking with me here dude
no problem!
Failed again 😦
full logs
I've updated this
SAme. here is the log
under the hood, what command does
python manage.py tailwind build
run?from the docs ........This will replace the development build with a bundle optimized for production. No further actions are necessary; you can deploy!
doesnt quite answer the question
also, why not just run that command locally and then deploy?
It's been run locally. In dev you run python manage.py tailwind build this watches for any styles changes and builds the css occordingly and is contained in it's own Django App.....python manage.py tailwind build compiles the CSS into the needed styles.
also doesnt answer the question 🫤
you gotta help me help you
I know i'm trying..
i know railway, you have to know your app
Totally.
Can you expand on this - "why not just run that command locally and then deploy", this was my initial thinking, I have my css file built via the build command ran locally, I wouldn't need Node isntall withing my Railway server at all
why not run this command locally, then push the changes that this command produces
Yes I have thought of that. Railway is seeing a package.json file and attempts to install Node......I assume it's a case of just removing from the repo
mope, overwrite the providers
yea ok, let me try and i'll sleep on it. Sorry for all this, one way to learn!
unless you are about to hope in bed, just update your file and deploy it
It published the image and deployed, it then crashed i'm get unrelated dB errors due to not setting localhost
that's progress
Yea i've yet to setup- postgres (within railway) so i'll sort that in morning and go from there
Sounds good
So yea sorry @Brody for taking up so much of your time due to my incompetence with this 🤦♂️ Indeed, building the tailwind css into static before committing is the way to do it. No need for node to run anything on Railways end. I got stuck down a rabbit hole.