Node Version

How i can change the node Version. also i can use canvas or ffmpeg in railway?
222 Replies
Percy
Percy2y ago
Project ID: N/A
stroos
stroosOP2y ago
N/A
Brody
Brody2y ago
1. set engines.node to 18 in your package.json - https://nixpacks.com/docs/providers/node#setup 2. nixpacks should detect you are using canvas and add the needed system packages - https://github.com/railwayapp/nixpacks/blob/main/src/providers/node/mod.rs#L132 3. i can provide you with a config to add ffmpeg if you want
stroos
stroosOP2y ago
Thanks for helping me yes pls give me the config also i can use node 16? cause 18 have problems with canvas
Brody
Brody2y ago
add this as a nixpacks.toml file to your project
[phases.setup]
nixPkgs = ["...", "ffmpeg"]
[phases.setup]
nixPkgs = ["...", "ffmpeg"]
node 16 is the default - https://nixpacks.com/docs/providers/node#setup
stroos
stroosOP2y ago
should i put engines in the package.json file oh nvm i just realized
stroos
stroosOP2y ago
Brody
Brody2y ago
node 16 is the default so that's not really necessary and even so, you can only specify a major version - https://nixpacks.com/docs/providers/node#setup
stroos
stroosOP2y ago
oh ok i hope it works
Brody
Brody2y ago
what are you deploying, if you don't mind me asking
stroos
stroosOP2y ago
ofc it's a discord bot for designers it can do some stuff for designers like get image colors or convert gif to mp4
Brody
Brody2y ago
sounds cool, I hope it works too
stroos
stroosOP2y ago
Brody
Brody2y ago
so far so good
stroos
stroosOP2y ago
og
stroos
stroosOP2y ago
i got this error
stroos
stroosOP2y ago
it's a problem with libuuid
Brody
Brody2y ago
Indeed, show me a screenshot of the table at the top of the build logs please
stroos
stroosOP2y ago
this?
stroos
stroosOP2y ago
stroos
stroosOP2y ago
if you want let me screen share for you iin voice
Brody
Brody2y ago
I'm good with screenshots
stroos
stroosOP2y ago
alright
Brody
Brody2y ago
but you have to send the screenshots I ask for that is not what I asked for unfortunately
stroos
stroosOP2y ago
ye but i don't get what part exactly you want where should i go
Brody
Brody2y ago
the table at the top of the build logs this would involve scrolling up the build logs to the top
stroos
stroosOP2y ago
im in the top
Brody
Brody2y ago
there would normally be a table there
stroos
stroosOP2y ago
hmm you can join the project?
Brody
Brody2y ago
what was that for?
stroos
stroosOP2y ago
i though it give me an answer sorry
Brody
Brody2y ago
please don't do that
stroos
stroosOP2y ago
i can remove that? ye sorry didn't know about it i can make you join the project? so you can see?
Brody
Brody2y ago
no thank you replace your current nixpacks.toml file with this
[phases.setup]
nixPkgs = ["...", "ffmpeg", "libuuid", "libGL"]
[phases.setup]
nixPkgs = ["...", "ffmpeg", "libuuid", "libGL"]
stroos
stroosOP2y ago
is this what you want?
Brody
Brody2y ago
yes it is
stroos
stroosOP2y ago
good
Brody
Brody2y ago
you are using puppeteer?
stroos
stroosOP2y ago
yes im am
Brody
Brody2y ago
can i ask what you are using that for?
stroos
stroosOP2y ago
if you know favocolor website im just getting informations for a color from this website
stroos
stroosOP2y ago
Keshav Naidu
FavoColor
Hex #FF0000 Color Code
Details of hex #FF0000 color code including RGB values, CMYK, HSL, Pantone, RAL, NCS and approximate color name. Download palettes of hex code #hexcode in addition to its shades, tones and tints.
stroos
stroosOP2y ago
is there a problem with that?
Brody
Brody2y ago
it would fall under web scraping and its generally discouraged in favor of using an official api, but you are getting colours from a website, youre fine
stroos
stroosOP2y ago
i changed the file like this and im redeploying i hope it works now yes
Brody
Brody2y ago
it is far slower and prone to issues, but meh its harmless enough in my opinion
stroos
stroosOP2y ago
they dont have an api
Brody
Brody2y ago
I know, but I'm sure someone has an api for what this website does, or implement it in pure JavaScript yourself, either way no big deal
stroos
stroosOP2y ago
oh no i searched so much anyway it just for one command
stroos
stroosOP2y ago
that's the table now
Brody
Brody2y ago
more things are now there, that's a good sign you must not be using the canvas package directly? otherwise nixpacks should have detected it
stroos
stroosOP2y ago
3 minutes lol
stroos
stroosOP2y ago
no im using canvas package directly
Brody
Brody2y ago
yeah remember when I said it's far slower, it's slower in more ways then one lol oh well, nixpacks has a little bug, what's new
stroos
stroosOP2y ago
hmm same error :'
Brody
Brody2y ago
fine, no more nix packages, we are moving to apt packages now
stroos
stroosOP2y ago
alr waiting you* 😸
Brody
Brody2y ago
you know what to do
[phases.setup]
aptPkgs = ["...", "ffmpeg", "libuuid1", "libgl1", "libgl-dev"]
[phases.setup]
aptPkgs = ["...", "ffmpeg", "libuuid1", "libgl1", "libgl-dev"]
stroos
stroosOP2y ago
table:
stroos
stroosOP2y ago
more things
Brody
Brody2y ago
indeed
stroos
stroosOP2y ago
im crying same
Brody
Brody2y ago
nixpacks hates me hates you too
stroos
stroosOP2y ago
absolutrly im checking something i put console.log(process.version) let check node version
Brody
Brody2y ago
its 16 you can see that in the table
stroos
stroosOP2y ago
oh ye im dumb
Brody
Brody2y ago
im preping the next thing we will try, hold tight
stroos
stroosOP2y ago
alr if i run it locally it can help?
Brody
Brody2y ago
no
stroos
stroosOP2y ago
Stack Overflow
return process.dlopen(module, path._makeLong(filename));
I am getting this error when running an example from OpenCV Node return process.dlopen(module, path._makeLong(filename)); ^ Error: /home/sunny/face/build/opencv/v5.0.0/Release/...
stroos
stroosOP2y ago
tthey say remove nodemodules and nstall again idk anyway im waiting you
Brody
Brody2y ago
you are doing something with opencv too?
stroos
stroosOP2y ago
what is this
Brody
Brody2y ago
nevermind send me your package.json please
stroos
stroosOP2y ago
WHAT sry caps
Brody
Brody2y ago
i dont even wanna get into that lol
stroos
stroosOP2y ago
wanna screenshot it
stroos
stroosOP2y ago
stroos
stroosOP2y ago
Brody
Brody2y ago
thats not what i meant nevermind
stroos
stroosOP2y ago
lol u have another thing to do?
Brody
Brody2y ago
no no delete your nixpacks.toml file, and then add this file to your project
stroos
stroosOP2y ago
ok
stroos
stroosOP2y ago
Brody
Brody2y ago
full build logs please
stroos
stroosOP2y ago
-----
> [2/7] RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg libuuid1 libgl1 libgl-dev:
#6 1.327 Err:12 http://deb.debian.org/debian stretch-updates/main amd64 Packages
#6 1.327 404 Not Found
#6 1.331 Reading package lists...
#6 1.345 W: The repository 'http://security.debian.org/debian-security stretch/updates Release' does not have a Release file.
#6 1.345 W: The repository 'http://deb.debian.org/debian stretch Release' does not have a Release file.
#6 1.345 W: The repository 'http://deb.debian.org/debian stretch-updates Release' does not have a Release file.
#6 1.345 E: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/main/binary-amd64/Packages 404 Not Found
#6 1.345 E: Failed to fetch http://deb.debian.org/debian/dists/stretch/main/binary-amd64/Packages 404 Not Found
#6 1.345 E: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/main/binary-amd64/Packages 404 Not Found
#6 1.345 E: Some index files failed to download. They have been ignored, or old ones used instead.
-----

Dockerfile:3
-------------------
2 |
3 | >>> RUN apt-get update && apt-get install -y --no-install-recommends \
4 | >>> ffmpeg \
5 | >>> libuuid1 \
6 | >>> libgl1 \
7 | >>> libgl-dev
8 |
-------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y --no-install-recommends ffmpeg libuuid1 libgl1 libgl-dev" did not complete successf
-----
> [2/7] RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg libuuid1 libgl1 libgl-dev:
#6 1.327 Err:12 http://deb.debian.org/debian stretch-updates/main amd64 Packages
#6 1.327 404 Not Found
#6 1.331 Reading package lists...
#6 1.345 W: The repository 'http://security.debian.org/debian-security stretch/updates Release' does not have a Release file.
#6 1.345 W: The repository 'http://deb.debian.org/debian stretch Release' does not have a Release file.
#6 1.345 W: The repository 'http://deb.debian.org/debian stretch-updates Release' does not have a Release file.
#6 1.345 E: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/main/binary-amd64/Packages 404 Not Found
#6 1.345 E: Failed to fetch http://deb.debian.org/debian/dists/stretch/main/binary-amd64/Packages 404 Not Found
#6 1.345 E: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/main/binary-amd64/Packages 404 Not Found
#6 1.345 E: Some index files failed to download. They have been ignored, or old ones used instead.
-----

Dockerfile:3
-------------------
2 |
3 | >>> RUN apt-get update && apt-get install -y --no-install-recommends \
4 | >>> ffmpeg \
5 | >>> libuuid1 \
6 | >>> libgl1 \
7 | >>> libgl-dev
8 |
-------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y --no-install-recommends ffmpeg libuuid1 libgl1 libgl-dev" did not complete successf
Brody
Brody2y ago
try this instead keep in mind I don't have your code to test with, so I'm just guessing here
stroos
stroosOP2y ago
hm what coode di u want exactly
Brody
Brody2y ago
don't worry about that right now, try the new dockerfile I just sent
stroos
stroosOP2y ago
#10 [6/6] RUN npm ci --omit=dev

#10 0.845 npm ERR! The `npm ci` command can only install with an existing package-lock.json or
#10 0.845 npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
#10 0.845 npm ERR! later to generate a package-lock.json file, then try again.
#10 0.853
#10 0.853 npm ERR! A complete log of this run can be found in:
#10 0.853 npm ERR! /root/.npm/_logs/2023-07-01T09_32_32_729Z-debug.log
#10 ERROR: process "/bin/sh -c npm ci --omit=dev" did not complete successfully: exit code: 1
-----
> [6/6] RUN npm ci --omit=dev:
#10 0.845 npm ERR! The `npm ci` command can only install with an existing package-lock.json or
#10 0.845 npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
#10 0.845 npm ERR! later to generate a package-lock.json file, then try again.
#10 0.853
#10 0.853 npm ERR! A complete log of this run can be found in:
#10 0.853 npm ERR! /root/.npm/_logs/2023-07-01T09_32_32_729Z-debug.log
-----

Dockerfile:17
-------------------
15 | RUN rm -rf node_modules
16 |
17 | >>> RUN npm ci --omit=dev
18 |
19 | CMD ["npm", "run", "start"]
-------------------
ERROR: failed to solve: process "/bin/sh -c npm ci --omit=dev" did not complete successfully: exit code: 1
#10 [6/6] RUN npm ci --omit=dev

#10 0.845 npm ERR! The `npm ci` command can only install with an existing package-lock.json or
#10 0.845 npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
#10 0.845 npm ERR! later to generate a package-lock.json file, then try again.
#10 0.853
#10 0.853 npm ERR! A complete log of this run can be found in:
#10 0.853 npm ERR! /root/.npm/_logs/2023-07-01T09_32_32_729Z-debug.log
#10 ERROR: process "/bin/sh -c npm ci --omit=dev" did not complete successfully: exit code: 1
-----
> [6/6] RUN npm ci --omit=dev:
#10 0.845 npm ERR! The `npm ci` command can only install with an existing package-lock.json or
#10 0.845 npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
#10 0.845 npm ERR! later to generate a package-lock.json file, then try again.
#10 0.853
#10 0.853 npm ERR! A complete log of this run can be found in:
#10 0.853 npm ERR! /root/.npm/_logs/2023-07-01T09_32_32_729Z-debug.log
-----

Dockerfile:17
-------------------
15 | RUN rm -rf node_modules
16 |
17 | >>> RUN npm ci --omit=dev
18 |
19 | CMD ["npm", "run", "start"]
-------------------
ERROR: failed to solve: process "/bin/sh -c npm ci --omit=dev" did not complete successfully: exit code: 1
Brody
Brody2y ago
do you all of a suddon not have a package-lock.json file??
stroos
stroosOP2y ago
ye i removed that i though mayeb it cause problems ill return it
Brody
Brody2y ago
i did not tell you to do that, you gotta run those kinds of things by me
stroos
stroosOP2y ago
sorry okay
Brody
Brody2y ago
run npm i --package-lock-only to bring it back
stroos
stroosOP2y ago
ill just install the packages again
Brody
Brody2y ago
bruh
stroos
stroosOP2y ago
lol i already run the command before u saod ur msg didnt know about that cmd it's ok npm is fast
Brody
Brody2y ago
okay push your changes
stroos
stroosOP2y ago
stroos
stroosOP2y ago
waiting
Brody
Brody2y ago
you just said npm was fast
stroos
stroosOP2y ago
not my internet lol
Brody
Brody2y ago
the command i gave you does not download all the packages again
stroos
stroosOP2y ago
ye im dumb
stroos
stroosOP2y ago
:'
Brody
Brody2y ago
biting my tongue
stroos
stroosOP2y ago
lol i like ur sense of humor
stroos
stroosOP2y ago
npm: u said im fast
stroos
stroosOP2y ago
why it's taking so loong lol
Brody
Brody2y ago
you sure like using outdated tech, npm 16 and deprecated packages https://discord.com/channels/713503345364697088/1124606251540680727/1124636073692250163
stroos
stroosOP2y ago
canvas dont work fine with node 18
Brody
Brody2y ago
says who
stroos
stroosOP2y ago
try use it with 18 and u will see
Brody
Brody2y ago
im built different, it would work for me
stroos
stroosOP2y ago
😸
Brody
Brody2y ago
but you are right, the canvas version you use from 2005 probably wouldn't work with node 18
stroos
stroosOP2y ago
ye it have bunch of problems hope it works i want to use my bot
stroos
stroosOP2y ago
stroos
stroosOP2y ago
i can show you the bot if it works if u want ofc
Brody
Brody2y ago
it is 6am for me, and i have not yet slept, unfortunately i dont have the time for a bot showcase, even in the unlikely case that this works
stroos
stroosOP2y ago
lol it's 10am for me where are you from
Brody
Brody2y ago
maple syrup
stroos
stroosOP2y ago
wt
Brody
Brody2y ago
wt
stroos
stroosOP2y ago
stroos
stroosOP2y ago
OMGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG omg omg it worked i can't beleive my eyes
Brody
Brody2y ago
now show me the service variables please
stroos
stroosOP2y ago
where is that
Brody
Brody2y ago
in the railway service
stroos
stroosOP2y ago
Brody
Brody2y ago
just as i thought alright im not touching that can of worms
stroos
stroosOP2y ago
what anyways i heard u can connect this with discord webhook is that true
Brody
Brody2y ago
please please read this entire page sometime soon https://docs.railway.app/develop/variables dont know what that means, i have never developed a single line of code for a discord bot
stroos
stroosOP2y ago
why is that i mean for what do
Brody
Brody2y ago
so you can stop hard coding your discord bot token, amoung other things
stroos
stroosOP2y ago
you mean i should put my token etc in env?
Brody
Brody2y ago
no, that's specifically what you should not do putting your bot token in a plain text file is not a good idea I don't even work for railway and I've already seen one too many bot tokens or database passwords because a user either stored them in the code or in a .env file
stroos
stroosOP2y ago
ooh so where should i put them lol
Brody
Brody2y ago
the service variables, this is why I asked you to read that docs page I just linked
stroos
stroosOP2y ago
oh i see and how i access to that in my code
Brody
Brody2y ago
I'm not just sending you things to read for funsies
stroos
stroosOP2y ago
ofc but i really want to thank you for helpinng me without you ill just delete my bot lol
Brody
Brody2y ago
for example if you set a BOT_TOKEN service variable you can access that in node with process.env.BOT_TOKEN
stroos
stroosOP2y ago
oh thats coool ill try that now
Brody
Brody2y ago
read the entire docs page I linked first please no skimming! start over with node 18 lol
stroos
stroosOP2y ago
😸
stroos
stroosOP2y ago
stroos
stroosOP2y ago
:)
Brody
Brody2y ago
where is your database hosted
stroos
stroosOP2y ago
mongo db
Brody
Brody2y ago
bruh
stroos
stroosOP2y ago
oh wait i get you i think us idk
Brody
Brody2y ago
you're something else
stroos
stroosOP2y ago
stroos
stroosOP2y ago
thats cool
Brody
Brody2y ago
nice name
stroos
stroosOP2y ago
running locally is better
Brody
Brody2y ago
alright bedge time for me
stroos
stroosOP2y ago
good night sir
Brody
Brody2y ago
can I mark this thread as solved?
stroos
stroosOP2y ago
yes thanks for helping again
Brody
Brody2y ago
no problem
stroos
stroosOP2y ago
is this gonna be deleted
Brody
Brody2y ago
no
stroos
stroosOP2y ago
cool cause i maybe i got problem again so i msg u youa re the best
Brody
Brody2y ago
I figured
stroos
stroosOP2y ago
wait i can friend you? if doesnt bother you?
Brody
Brody2y ago
hopefully you will troubleshoot this and have it solved before I awake
stroos
stroosOP2y ago
lol i hope so
Brody
Brody2y ago
sorry no, railway said I can't have any friends
stroos
stroosOP2y ago
oh ok not cool from railway @Brody i can't run puppeteer in railway?
Adam
Adam2y ago
You can
stroos
stroosOP2y ago
hmm im like getting this error Error: Failed to launch the browser process!
Adam
Adam2y ago
you probably have to use a headless version
Brody
Brody2y ago
there's flags too have to pass the constructor send me the code that starts puppeteer please
LaCrak27
LaCrak272y ago
yes, it will pass on an embed to a channel to notify about build states
LaCrak27
LaCrak272y ago
like this
Brody
Brody2y ago
they already figured that out lol
LaCrak27
LaCrak272y ago
huh i must be blind then
LaCrak27
LaCrak272y ago
i am now blind my bad :(
Brody
Brody2y ago
no worries @stroos - please don't open old threads
stroos
stroosOP2y ago
alriight sorry
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox', '--disabled-setupid-sandbox'],
ignoreHTTPSErrors: true,
});
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox', '--disabled-setupid-sandbox'],
ignoreHTTPSErrors: true,
});
Brody
Brody2y ago
and what version are you using
stroos
stroosOP2y ago
19.4.1
Brody
Brody2y ago
a version from december of 2022, you just love using outdated stuff dont you you keep disappearing and making this process 10x longer then it normally would be lol
stroos
stroosOP2y ago
lol sry i was buying croissant 🥐 for my family anyway I put the version 17 but it still don't work this version npm install puppeteer@~17.1.3 --save feel free to ping me when you come hmm u took so long lol
LaCrak27
LaCrak272y ago
this is community support, people need to keep up with their lives, just be patient :)
stroos
stroosOP2y ago
i know im just kidding lol
Brody
Brody2y ago
I went to sleep lol
stroos
stroosOP2y ago
oh cool u slept good
Brody
Brody2y ago
and why would you try 17???? 17 is much older?? we don't want old, we want new
stroos
stroosOP2y ago
in digitalocean with this version it work fine oh wait ill update
Brody
Brody2y ago
put it back to 19.4.1 though, 19.4.1 works just fine
stroos
stroosOP2y ago
ill put latest
Brody
Brody2y ago
no 19.4.1 please
stroos
stroosOP2y ago
alr then 19.4.1 okai done
Brody
Brody2y ago
latest version has api changes
stroos
stroosOP2y ago
okai whats next step
Brody
Brody2y ago
you know what to do I have tested that with puppeteer 19.4.1 and it worked
stroos
stroosOP2y ago
cool
stroos
stroosOP2y ago
stroos
stroosOP2y ago
there is no command to make it run not install the packages from the beggining
Brody
Brody2y ago
what
stroos
stroosOP2y ago
railway up it push your files it also take time cause it install pckages there is a comand like for example railway push without installing the packages agaain
Brody
Brody2y ago
not how it works
stroos
stroosOP2y ago
good worked
stroos
stroosOP2y ago
what do you think about it?
Brody
Brody2y ago
I think you could probably find an API for colours, or implement that in code yourself, as opposed to relying on a web browser to navigate to a website for you
stroos
stroosOP2y ago
lfg think it's cool
Brody
Brody2y ago
I just really don't like scrapping sites with a web browser, it's slow and prone to failure the bot is still cool though
stroos
stroosOP2y ago
im new to web scrapping i just use it fo this but i heard cheerio is better thanks
Brody
Brody2y ago
better? yes. the best? no, use an API lol
stroos
stroosOP2y ago
😭 if they have an api why ill use pupetter :-
Brody
Brody2y ago
but yeah everything works now?
stroos
stroosOP2y ago
YES THANKS
Brody
Brody2y ago
awesome, no problem!
Want results from more Discord servers?
Add your server