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
Percy2y ago
Project ID: fd98a4cb-a823-467e-b701-d42af92842f9
rageoffire
rageoffireOP2y ago
fd98a4cb-a823-467e-b701-d42af92842f9
Brody
Brody2y ago
can i see your repo so i can understand this better?
rageoffire
rageoffireOP2y ago
where can I share it ? It a private source code I buy from a person
Brody
Brody2y ago
you can send it here, no one here is gonna do anything bad
rageoffire
rageoffireOP2y ago
Here is my project (I have delete some files in it)
jackson
jackson2y ago
there's nothing in there
rageoffire
rageoffireOP2y 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
Brody2y ago
Dockerfile
Adam
Adam2y 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
rageoffireOP2y ago
I have send you a source You mean I can generation my own dockerfile right ?
Adam
Adam2y ago
Thank you, I'll take a look
rageoffire
rageoffireOP2y ago
Oh I see it
Brody
Brody2y ago
adam will get you sorted, i know hes done similar setups before
jackson
jackson2y ago
this is such a const _0x2cc0f8 = _0x3ed65d; moment
Adam
Adam2y 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
rageoffireOP2y ago
It for a server that run with a plugin (from game) for my RPGmaker game to allow multiplayer game
Adam
Adam2y 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
rageoffireOP2y ago
yes that want I need
Adam
Adam2y ago
you can chain commands together by separating them with a semicolon like so:
cd foldername; npm install
cd foldername; npm install
rageoffire
rageoffireOP2y 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
rageoffireOP2y ago
Brody
Brody2y 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
rageoffireOP2y 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
rageoffireOP2y ago
rageoffire
rageoffireOP2y ago
and then go to root folder run index.js file
rageoffire
rageoffireOP2y ago
Brody
Brody2y 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
rageoffireOP2y 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
Brody2y ago
@RageOfFire done
Brody
Brody2y 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
rageoffireOP2y 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
Brody2y 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
rageoffireOP2y 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
Brody2y 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
rageoffireOP2y ago
wow success in first time you are gold
Brody
Brody2y ago
lol thanks, have fun with your game dev stuff!
Want results from more Discord servers?
Add your server