Build a node pack inside and then run .js file outside

Anyone know how to to build a package inside a folder like this folder1/folder2/package.json and then run a index.js in root folder
39 Replies
Percy
Percy16mo ago
Project ID: fd98a4cb-a823-467e-b701-d42af92842f9
rageoffire
rageoffire16mo ago
fd98a4cb-a823-467e-b701-d42af92842f9
Brody
Brody16mo ago
can i see your repo so i can understand this better?
rageoffire
rageoffire16mo ago
where can I share it ? It a private source code I buy from a person
Brody
Brody16mo ago
you can send it here, no one here is gonna do anything bad
rageoffire
rageoffire16mo ago
Here is my project (I have delete some files in it)
jackson
jackson16mo ago
there's nothing in there
rageoffire
rageoffire16mo ago
exastly my main point is to deploy project to railway and run npm install inside Server/Core/Server and then go outside to execute node index.js
Brody
Brody16mo ago
Dockerfile
Adam
Adam16mo ago
You can send it to me, I can review Won't share it If you delete files it will be near impossible to help you
rageoffire
rageoffire16mo ago
I have send you a source You mean I can generation my own dockerfile right ?
Adam
Adam16mo ago
Thank you, I'll take a look
rageoffire
rageoffire16mo ago
Oh I see it
Brody
Brody16mo ago
adam will get you sorted, i know hes done similar setups before
jackson
jackson16mo ago
this is such a const _0x2cc0f8 = _0x3ed65d; moment
Adam
Adam16mo ago
@RageOfFire Can you please explain what the code is supposed to do? I'm working on running it on my own pc, would be helpful to know what the expected behaviour is
rageoffire
rageoffire16mo ago
It for a server that run with a plugin (from game) for my RPGmaker game to allow multiplayer game
Adam
Adam16mo ago
Ah great, thank you Sounds like you want to add cd commands before your build command, then cd commands to get out of that folder to run your start command
rageoffire
rageoffire16mo ago
yes that want I need
Adam
Adam16mo ago
you can chain commands together by separating them with a semicolon like so:
cd foldername; npm install
cd foldername; npm install
rageoffire
rageoffire16mo ago
Dockerfile:15
-------------------

13 | # build phase
14 | COPY . /app/.
15 | >>> RUN cd Core/Server; npm install
16 |
17 |
-------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c cd Core/Server; npm install" did not complete successfully: exit code: 127

Error: Docker build failed
Dockerfile:15
-------------------

13 | # build phase
14 | COPY . /app/.
15 | >>> RUN cd Core/Server; npm install
16 |
17 |
-------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c cd Core/Server; npm install" did not complete successfully: exit code: 127

Error: Docker build failed
so here what I get when redeploy
rageoffire
rageoffire16mo ago
Brody
Brody16mo ago
okay start by giving me a list of commands youd run to build this app locally starting from the root of the project folder
rageoffire
rageoffire16mo ago
first of all I gonna to npm install it in Core/Server but I using window right now so normal I just gonna to head into that folder and open to command promt
rageoffire
rageoffire16mo ago
rageoffire
rageoffire16mo ago
and then go to root folder run index.js file
rageoffire
rageoffire16mo ago
Brody
Brody16mo ago
okay i will think ill get back to you in a little while you have tried deploying right? can you show me that little table in the top of the build logs?
rageoffire
rageoffire16mo ago
https://pastebin.com/GnBE9ji3 here is full build log
Pastebin
Sticky cache enabled==============Using Nixpacks==============conte...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Brody
Brody16mo ago
@RageOfFire done
Brody
Brody16mo ago
add this file to the root of your project in settings.json you have port defined as 1906, so in the service variables set PORT = 1906 im pretty sure that file will override any build or start commands in the service settings, but just to be safe, clear them before you make a new deployment
rageoffire
rageoffire16mo ago
Thank you very much this working now ! My only problem left is I still can't connect to server seem port error now. I just generation a domain https://domain.up.railway.app/ do it need time to exist to internet ?
Brody
Brody16mo ago
it would typically be accessible within a few seconds of creation make sure you are using https as a scheme and are not trying to connect to the railway domain with any other port than 443 (aka no port since it's implied with https as the scheme)
rageoffire
rageoffire16mo ago
oh lol 443 overwrite my port XD so now port 1906 kind of useless now everything go to 443 thank you very much everything work perfectly fine now
Brody
Brody16mo ago
well you can only access your app over 443, you can't open other ports so railway forwards all traffic between the internal port 1906 and 443 but awesome, glad I could help, this was my first time writing up a railway.json config file!
rageoffire
rageoffire16mo ago
wow success in first time you are gold
Brody
Brody16mo ago
lol thanks, have fun with your game dev stuff!