Update NodeJS or stop yarn from building resource?

Hello, I’m just playing around with a resource, using javascript (nodejs).

More specifically, I’m using a package that requires node to be above version 16.10.0.
Which FiveM’s node engine does not seem to be.

Therefore, I’m wondering if there is some way to stop yarn from building the resource since it is unneeded.
Or if there is some way to upgrade the node engine that FiveM uses (my personal node version is 18, not 16)

One solution would be to make sure the package.json file is not in the root directory, although that is not really that nice of a solution

Things I’ve already tried:

  • Manually creating a .yarn.installed file, which does work for a little while, but stops working due to yarn’s date checks

Thank you

Hi, I have same problem. Do you find some solution?

Well, there are some different ways to do it:

  • Remove yarn/webpack from your server, as they are anyways not needed (not really ideal if you’re gonna sell the resource, but would work if you are developing your own server)
  • Create another folder in your root resource folder, and move your NodeJS files there, so that the package.json file isn’t in the main resource folder.
  • Modify the yarn resource to check for some special property and don’t build if that is present
1 Like

I created a variant of the yarn resource with the last feature in my previous message, which would probably be the ideal solution.

Do as you wish with it.

1 Like

Yep, but you will get error with node modules.

[script:rd_DiscordBot] Error loading script index.js in resource rd_DiscordBot: SyntaxError: Unexpected token ‘{’
[script:rd_DiscordBot] stack:
[script:rd_DiscordBot] C:\Users\joubs\Desktop\txData\ESXLegacy_BBB22F.base\resources\rd_DiscordBot\node_modules@discordjs\rest\dist\index.js:174
[script:rd_DiscordBot] static {
[script:rd_DiscordBot] ^
[script:rd_DiscordBot]
[script:rd_DiscordBot] SyntaxError: Unexpected token ‘{’
[script:rd_DiscordBot] at Object.compileFunction (node:vm:352:18)
[script:rd_DiscordBot] at wrapSafe (node:internal/modules/cjs/loader:1031:15)
[script:rd_DiscordBot] at Module._compile (node:internal/modules/cjs/loader:1065:27)
[script:rd_DiscordBot] at Object.Module._extensions…js (node:internal/modules/cjs/loader:1153:10)
[script:rd_DiscordBot] at Module.load (node:internal/modules/cjs/loader:981:32)
[script:rd_DiscordBot] at Function.Module._load (node:internal/modules/cjs/loader:822:12)
[script:rd_DiscordBot] at Module.require (node:internal/modules/cjs/loader:1005:19)
[script:rd_DiscordBot] at require (node:internal/modules/cjs/helpers:94:18)
[script:rd_DiscordBot] at Object. (C:\Users\joubs\Desktop\txData\ESXLegacy_BBB22F.base\resources\rd_DiscordBot\node_modules\discord.js\src\client\BaseClient.js:4:18)
[script:rd_DiscordBot] at Module._compile (node:internal/modules/cjs/loader:1101:14)

That’d be related to the way you are building/bundling it.
Or the fact that you might be using an unsupported discord.js version.

I don’t think that would be caused by the yarn/webpack resource.

Personally, I use these dep versions without any issues
(FiveM uses an outdated nodejs version, so you cant use the latest one)

"dependencies": {
  "@discordjs/builders": "^1.6.5",
  "@discordjs/rest": "^2.0.1",
  "discord-api-types": "^0.37.62",
  "discord.js": "^13.17.1"
}
1 Like

thx <3

1 Like

Hello, it’d be hard to help you without seeing the actual error you’re encountering.