7

How to fix Depricated warning message (node:6136) DeprecationWarning: 'GLOBAL' is deprecated, use 'global'

In my code I have used something like below

// initializing globals
GLOBAL.user_session= {};
GLOBAL.config= require('./config/config.js');

So how to fix warning message?

KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133
Haresh Vidja
  • 8,340
  • 3
  • 25
  • 42
  • 14
    The warning tells you the answer! – robertklep Aug 09 '16 at 09:50
  • 11
    It's not concise. No question is a dumb question. It doesn't simply say "Use lowercase global instead of uppercase"... the idea of needing that is slightly odd. I've been coding for twenty years and give lectures and I figured I'd google it just to make sure... and lo... stack overflow bequeathed an answer that yielded confidence to move forward with my life... now I can sip my coffee in total peace. – Nick Steele Dec 20 '16 at 15:08
  • 1
    I don't use either and I still get that working... – Gerry Feb 08 '19 at 18:58
  • Does this answer your question? [Global variables for node.js standard modules?](https://stackoverflow.com/questions/4140661/global-variables-for-node-js-standard-modules) – KyleMit Jan 12 '20 at 04:16
  • I'm new to Node (v12.18.3) and I'm getting this warning even though my very simple app.js does not make use of global at all. I'm requiring 'express' (4.17.1), nothing else. How can I debug what is causing this warning? – Nick Aug 13 '20 at 01:47

1 Answers1

16
global.user_session= {};
global.config= require('./config/config.js');
CD..
  • 72,281
  • 25
  • 154
  • 163