Issue building project with advanced configuration on Node with express and mongoose

Feature(s) impacted

Building of the project is waylaid as Node throws and error on build.

Observed behavior

On build of the server, debug throws the following error:

Uncaught SyntaxError C:\Users\jakec\source\project-root\server\node_modules\@forestadmin\agent\dist\agent.js:187
        if (!experimental?.webhookCustomActions && isProduction) {

Expected behavior

I was expecting the server to build without error.

Context

  • Project name: NFPD
  • Team name: FRSS
  • Environment name: Unsure
  • Agent (forest package) name & version:
    @forestadmin/agent”: “^1.35.2”,
    @forestadmin/datasource-mongoose”: “^1.5.25”,
  • Database type: noSQL MongoDB
  • Recent changes made on your end if any: This is the initial integration of this Forest into my project.

Hello @Jacob_Carpenter and welcome to our community :tada: :tada:,

Can you tell me which version of node you are using? :pray:

Kind regards,

Florian

Of Course, we are on Node 18.18.0 but downgrading to 16.13.0 results in the same issue.

It’s very strange if your node version is up to date. :thinking: Apparently the optional chaining operator syntax (?. ) has been supported since node version 14. Do you use special things like babel or similar?

we use “@babel/eslint-parser”: “7.21.8”

Our babelrc is just a single line
{
“plugins”: [“@babel/plugin-syntax-optional-chaining”]
}

I I think your problem is linked to Babel :thinking:, which must not support this type of operator. Can you try updating babel? :pray:

I had success just editing out the operator that was throwing errors. I had removed babel entirely but still had the same issue, so I may just need to fork the repo for my particular use case. That said I am having one more issue that I can’t seem to find any resources on. I have a ‘Profile’ Service that acts as a way to peel off sensitive data from my Account model but it seems forest is trying to find a complete DB collection for it. It’s throwing this error:

Uncaught Error Error: Collection ‘Profile’ not found. List of available collections: Account, Value

I imagine this is happening because I have a profile controller and service but no DB collection, I’m just not sure how to fix it.

Hello @Jacob_Carpenter :wave:,

I’m having trouble understanding why you have a problem with forest. :thinking: Could you share a repo with the project that’s causing the problem (or, if it contains sensitive data, a project with the minimum amount of code that reproduces the problem)? :pray: It would help me a lot.

Kind regards,

Florian