Error on migration from Meteor 2.14.0 to 3.0-beta.6

Hi guys, I just started to migrate an application from 2.14.0 version to 3.0-beta.6. I already did a lot of updates in some packages I use, and they are seeing fine. But I’m getting an weird error when I start the app. The line of that the error is indicating is a declaration of a global variable. I guess can be something easy to solve (at this moment I use a global variable for many things). CODE:

import SimpleSchema from "simpl-schema";

App = {}

ERROR:

> app@0.0.1 start
> meteor run --settings .deploy/dev/dev.settings.json

[[[[[ ~/Workspaces/sbb/color-admin ]]]]]      

=> Started proxy.                             
=> Started MongoDB.                           
I20240309-11:46:31.455(-6)? Meteor._wrapAsync has been renamed to Meteor.wrapAsync
W20240309-11:46:31.836(-6)? (STDERR) packages/core-runtime.js:205
W20240309-11:46:31.837(-6)? (STDERR)             throw error;
W20240309-11:46:31.837(-6)? (STDERR)             ^
W20240309-11:46:31.837(-6)? (STDERR) 
W20240309-11:46:31.837(-6)? (STDERR) ReferenceError: App is not defined
W20240309-11:46:31.837(-6)? (STDERR)     at module.wrapAsync.self (lib/_app.js:3:4)
...
1 Like

are you able to change:

App = {}

to

const App = {}

I would love to see a reproduction so that I can test it and maybe get into a solution for this package.

If I put const it is not more a global variable. I’m trying to create a reproduction code. For now, just in my project.

1 Like

Oh, if you use globalThis it could work from what I understand.

globalThis.App = {}

am also migrating from 2.x to 3.x, and found that prepending either “const” or “globalThis.” to existing global variables resolved “is not defined” errors as well. It seems this adjustment is necessary for both common and server-side code, while some global variables in client-side code continue to work without modification. Is there any official guidance or best practices for handling this?

Using const removes the error but it changes the code behavior as the variable becomes local to where it is defined