Home > OS >  ReferenceError: globalThis is not defined Node.js
ReferenceError: globalThis is not defined Node.js

Time:01-21

need help. does anybody faced this issue while deploying code on server? Everything is working fine on local.

ReferenceError: globalThis is not defined

Server setup: ECS fargate- docker container with Bitbucket pipeline

Node: 10 defined in docker

Server is keeps getting reloaded because of this issue.

CodePudding user response:

globalThis is only available in Node v12 and newer so you cannot use it if you are using Node v10.

If it's your own code, you can use global instead, which is the same thing.

If the error is not coming from your own code, you'll have to upgrade your node version or get rid of the dependency it's coming from.

Note than Node v10 is no longer supported. It hasn't received any updates, including security updates, in a long time. If at all possible, you should upgrade to a supported version of Node (at the time of this writing, 18 is the latest LTS release).

  • Related