#Hi!

119 messages · Page 1 of 1 (latest)

vapid dirge
#

I have a problem trying to deploy my app. I recognize is quite tricky but it's the best solution I found to have the structure I need.

My app it's a Vite/ReactJS app and it runs perfectly, but I need to create a blog so I decide to create a solution with Astro inside my Vite/ReactJS app.

So my structure looks like a tipical ReactJS app but I created a /blog folder with a Astro project and I modified my build script and looks like this

"build": "vite build && cd blog && npm run build"

vite build works fine but I have a problem with Astro

24.63 sh: 1: astro: not found
24.66 error Command failed with exit code 127.
24.66 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Looks like astro build it's not working. I try to add engine: 18 on my package.json but it doesn't works.

Thanks for your help and patience

atomic flaxBOT
#

Project ID: 863d09e4-f366-4c2c-90bc-5991b840e2a0

orchid orbitBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

north arrow
#

could you share your repo, that would give us the best possible overview of what you are trying to do

vapid dirge
#

863d09e4-f366-4c2c-90bc-5991b840e2a0

#

It's private but If you want I can share with your github user

north arrow
#

yes please, brody192

vapid dirge
#

Ok I just added you

north arrow
#

any specific branch i should be looking at?

vapid dirge
#

main directly

north arrow
#

so you just want to deploy the app within /blog and dont care about anything in the root?

vapid dirge
#

yeah my idea it's to deploy the asto into the dist folder like an static project

#

so I think this approach it was the best to achive it

#

making both builds at the same time

north arrow
#

does anything in /blog depend on anything outside of /blog?

vapid dirge
#

nope

#

It's independent

north arrow
#

perfect, so first things first, you will need to configure your blog app to use the node adapter

vapid dirge
#

makes sense ok

north arrow
#

let me know when done!

#

there is steps after this, but one thing at a time

vapid dirge
#

ok, I just pushed the node adapter

north arrow
#

that was fast, ill take a look

#

missed the server object

vapid dirge
#
  server: {
    host: '0.0.0.0'
  },
#

ok added

north arrow
#

okay in the blog's package.json set the start script to node dist/server/entry.mjs and also remove any build or start commands you may have set in your services settings

vapid dirge
#

👍🏻

#

OK the scripts in the blog looks like this

  "scripts": {
    "dev": "astro dev",
    "start": "node dist/server/entry.mjs",
    "build": "astro build",
    "preview": "astro preview",
    "astro": "astro"
  },
north arrow
#

looks good, now just set the root directory in the service settings to /blog

vapid dirge
#

ok its redeploying

#

it fails

north arrow
vapid dirge
#

sorry the tool doesn't works but heres the log

north arrow
#

what browser are you using?

vapid dirge
#

chrome

#

ok now works

north arrow
#

always has

vapid dirge
#

it was my fault sorry

north arrow
#

can you run npm run build locally?

vapid dirge
#

ok

#

on root right?

#

i have an error

#
Cannot find package '@astrojs/internal-helpers' imported from /Users/elchiconube/Projects/personal/memos.land/frontend/dist/blog/dist/server/manifest_YLt2YtOP.mjs
  Stack trace:
    at new NodeError (node:internal/errors:405:5)
    at moduleResolve (node:internal/modules/esm/resolve:939:20)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at link (node:internal/modules/esm/module_job:76:36)
north arrow
#

in the blog folder run npm run build

vapid dirge
#

ah ok

#

same issue

#
Cannot find package '@astrojs/internal-helpers'
north arrow
#

okay please get your app building locally

vapid dirge
#

i'm adding this package

#

mmm looks like i need to install multiple packages but not sure if do it on blog or root directory

north arrow
#

blog is isolated from the rest as youve said

vapid dirge
#

oki

#

ok looks like locally runs fine I just pushed

#

it fails again

north arrow
#

in the blog folder, can you run npm run build locally?

vapid dirge
#

yes, I just pushed again with the yarn.lock file

north arrow
#

locally do you use yarn or npm?

vapid dirge
#

I used to use yarn

north arrow
#

what do you use now?

vapid dirge
#

If i try yarn build in the root I see this error

"default" is not exported by "ckeditor5/build/ckeditor.js", imported by "src/components/MemoryEditor.jsx
#

I prefer yarn

north arrow
#

im not sure why you are trying to do stuff in the root? this thread is about running the blog on railway, right?

vapid dirge
#

yes sorry

north arrow
#

can you build the blog locally with yarn?

vapid dirge
#

yes

#

works fine in my local

north arrow
#

what command do you run locally yo build blog?

#

and what folder are in you when you do that?

vapid dirge
#

npm run build

north arrow
vapid dirge
north arrow
#

what version of node are you using locally

vapid dirge
#

v18.18.0

#

i saw this in the build log

#12 4.663 Cannot find package 'cookie' imported from /dist/blog/dist/server/manifest_YyjHGfxx.mjs

I added in my local and the build works fine

#

but It doesn't work on server 😦

north arrow
#

whats your root directory set to on your railway service?

vapid dirge
north arrow
#

unfortunately i dont know why you get that error, but it is a code issue, so please try your best to resolve it

vapid dirge
#

mmm looks like it´s something related with the adapter

#

if I set it to static it deploys fine, but it crash because the adapter node its for output server

#

so I think its not a code issue it works fine in my local

north arrow
#

for railway, it needs to use a node adapter

#

this isnt an issue with railway, i know that much

vapid dirge
#

maybe its not compatible

#

also it's so strange i need to add packages manually that I dont use in my code

north arrow
#

i have an astro template and it works just fine, this isnt an issue with railway

vapid dirge
#

looks like astro in server output needs something that it´s not compatible with the build process

#

mmm if I put your template into the blog folder should be fine?

north arrow
#

some kinda of config / code issue on your part

#

yeah theoretically

vapid dirge
#

I'll try

north arrow
vapid dirge
#

mmm yes but my configuration its something more complex. I have my reactJs and the astro blog

north arrow
#

you said blog is completely separate and doesn’t rely on anything outside of the blog folder

#

you cant copy in 1/4 of the astrowind project and expect it to build

vapid dirge
#

sorry maybe I didn't explain what I need.

  1. Build my Vite/React app
    2.Build my Astro blog and put it into the Vite/React /dist/blog folder
#

That's why my first idea was change my build script into the React app into this

 "build": "cd blog && astro build && cd .. && vite build",
#

Is it possible?

north arrow
#

yes but thats not a good idea in my opinion, can we instead have your react app on domain.com, and your blog on blog.domain.com?

vapid dirge
#

Well I'm planning to have a great url

domain.com/blog/first-blog
domain.com/blog/es/primer-blog
domain.com/blog/en/primer-blog

north arrow
#
blog.domain.com/first-blog
blog.domain.com/es/primer-blog
blog.domain.com/en/primer-blog
vapid dirge
#

I get it

#

ok

north arrow
#

thats the better solution in my opinion, its how railway does it too

vapid dirge
#

but why it's not a good idea my first approach?

north arrow
#

you are building two completely separate apps and then combining them, im sure i could work out a decent way to do that, but blog.domain.com is far better and more appropriate

vapid dirge
#

mmm ok. I'll think about it. Thanks for your time @north arrow . I really appreciate it ❤️

north arrow
vapid dirge
#

My other idea was to move everything to NextJS but it's to hard to move everything to NextJS just because I need a blog in my project mildpanic

vapid dirge
north arrow
#

so yeah, going forward you want an isolated mono repo.
in the repo you want two folders
/blog
and
/mysite (or whatever you wanna name it)
then in railway you will have two services, each set with the appropriate root dir and with the applicable domain added

#

astro still needs to build with the node adapter though, so you still need to sort those build errors out

vapid dirge
#

Ok will try your solution creating a subdomain. Thanks