TypeError : Cannot read properties of undefined (reading 'map') on deployment

Hello, there, i’m trying to deploy my app on my server but i get this error, triggering right after the server starts :

remote:        info: Successfully mounted on Standalone server (http://0.0.0.0:3000)
remote:        [ Server On ]
remote:        /usr/src/app/node_modules/@forestadmin/forestadmin-client/dist/schema/index.js:22
remote:                const data = schema.collections.map(c => ({ id: c.name, ...c }));
remote:                                                ^
remote:        TypeError: Cannot read properties of undefined (reading 'map')
remote:            at SchemaService.serialize (/usr/src/app/node_modules/@forestadmin/forestadmin-client/dist/schema/index.js:22:41)
remote:            at SchemaService.postSchema (/usr/src/app/node_modules/@forestadmin/forestadmin-client/dist/schema/index.js:14:38)
remote:            at ForestAdminClientWithCache.postSchema (/usr/src/app/node_modules/@forestadmin/forestadmin-client/dist/forest-admin-client-with-cache.js:25:35)
remote:            at Agent.sendSchema (/usr/src/app/node_modules/@forestadmin/agent/dist/agent.js:152:62)
remote:            at async Promise.all (index 1)
remote:            at async Agent.start (/usr/src/app/node_modules/@forestadmin/agent/dist/agent.js:57:26)
remote:        Node.js v18.14.0

I don’t have any problem in my local environment…

I’m using forest agent 1.6.1 and the mongoose datasource v1.2.4

Any hint about where my problem could be ?

Most probable cause sounds like a mismatch between versions of different @forestadmin packages.

Specifically, between the @forestadmin/agent and @forestadmin/forestadmin-client package.

Can you upgrade all @forestadmin packages that are installed on your project to the latest version and try again?

Also, if your project explicitly depends on @forestadmin/forestadmin-client, it’s more than likely that you can drop that dependency, as it is internal

Thanks for reply !
Sounds weird to me as i don’t got the package @forestadmin/forestadmin-client.
Maybe i missed something during installation ?
Or is this what you said : i do not need the package explicitly to run forest ?
Here’s my old package.json dependancies :

  "dependencies": {
    "@forestadmin/agent": "^1.6.1",
    "@forestadmin/datasource-mongoose": "^1.2.4",
    "chalk": "^5.2.0",
    "cloudinary": "^1.33.0",
    "cors": "^2.8.5",
    "dotenv": "^16.0.3",
    "express": "^4.18.2",
    "mongoose": "^6.8.3",
    "morgan": "^1.10.0",
    "sharp": "^0.31.3"
  }

I updated to “@forestadmin/agent”: “^1.8.2”, “@forestadmin/datasource-mongoose”: “^1.3.1” but i still get the error.
Tried to install the package explicitly and still got the same error.

I ran 2 deploys with theses versions :

"dependencies": {
    "@forestadmin/agent": "^1.8.2",
    "@forestadmin/datasource-mongoose": "^1.3.1",
    [...others dependancies...]
  }
"dependencies": {
    "@forestadmin/agent": "^1.8.2",
    "@forestadmin/datasource-mongoose": "^1.3.1",
    "@forestadmin/forestadmin-client": "^1.1.9",
    [...others dependancies...]
  }

Error message is weird tho, how could map() be undefined in node 18+ ?
To give more intels : I’m trying to deploy on an Ubuntu server, into Docker container managed by Dokku and i use pnpm localy to develop.

Here’s my Dockerfile :

FROM node:18-alpine
WORKDIR /usr/src/app
COPY . .
RUN npm install -s
CMD ["npm", "start"]

Watching the source code of forest admin client, i cannot find out why this error message is showing as the native Array.map() is not replaced in the project…

I’m a bit confused about how i get it to work and i did not encouter this problem whith the old version of Forest Admin, deployed on the exact same environment (created 1 year ago).

Could networking of my container be a problem here ? As it crashed on the sending of the schemas…

I’ll try to reproduce this.
I’ll come back to you in a minute

Just tested with the versions that you provided, and everything seems to work on my end.

Can you:

  • drop node_modules / package-lock.json / yarn.lock and try reinstalling
  • provide me with the output of npm ls --depth 2
1 Like

Okay it’s working now but it’s not expected… I mean i destroyed my container (Because i couldn’t push anymore with failing build).

Then based on what you said i added my lockfile (pnpm-lock.yaml) into .gitignore, delete node_modules and the lockfile, commit and tried to repush then it works.

Well, thank you !

(Pretty sure it was because i use pnpm in local and npm on the distant machine)

1 Like