Migration to 3.0 | SimpleSchema is not defined

I’ve started to migrate my app, but I’m running into some issues.

Here’s the errors I get when trying to run:
Unable to resolve some modules:

 "diagnostics_channel" in /c/AutoSpecsPro/app/node_modules/undici/lib/core/diagnostics.js (web.browser)
  "perf_hooks" in /c/AutoSpecsPro/app/node_modules/undici/lib/web/fetch/util.js (web.browser)
  "util/types" in /c/AutoSpecsPro/app/node_modules/undici/lib/web/fetch/util.js (web.browser)
  "worker_threads" in /c/AutoSpecsPro/app/node_modules/undici/lib/web/fetch/webidl.js (web.browser)
  "http2" in /c/AutoSpecsPro/app/node_modules/undici/lib/dispatcher/client-h2.js (web.browser)
  "async_hooks" in /c/AutoSpecsPro/app/node_modules/undici/lib/api/api-request.js (web.browser)

If you notice problems related to these missing modules, consider running:

  meteor npm install --save meteor-node-stubs

=> Started MongoDB.
W20250123-13:12:18.275(-6)? (STDERR) packages\core-runtime.js:189
W20250123-13:12:18.292(-6)? (STDERR)             throw error;
W20250123-13:12:18.293(-6)? (STDERR)             ^
W20250123-13:12:18.293(-6)? (STDERR)
W20250123-13:12:18.293(-6)? (STDERR) ReferenceError: SimpleSchema is not defined
W20250123-13:12:18.294(-6)? (STDERR)     at module (lib/collections/AddedInfo.js:40:28)
W20250123-13:12:18.294(-6)? (STDERR)     at fileEvaluate (packages\modules-runtime.js:335:7)
W20250123-13:12:18.294(-6)? (STDERR)     at Module.require (packages\modules-runtime.js:237:14)
W20250123-13:12:18.295(-6)? (STDERR)     at Module.mod.require (C:\Users\Dusty\AppData\Local\.meteor\packages\modules\0.20.3\npm\node_modules\@meteorjs\reify\lib\runtime\index.js:30:33)
W20250123-13:12:18.295(-6)? (STDERR)     at Object.require (packages\modules-runtime.js:257:21)
W20250123-13:12:18.295(-6)? (STDERR)     at evaluateNextModule (packages\core-runtime.js:167:26)
W20250123-13:12:18.296(-6)? (STDERR)     at evaluateNextModule (packages\core-runtime.js:202:7)
W20250123-13:12:18.296(-6)? (STDERR)     at runEagerModules (packages\core-runtime.js:206:3)
W20250123-13:12:18.296(-6)? (STDERR)     at processNext (packages\core-runtime.js:128:3)
W20250123-13:12:18.296(-6)? (STDERR)     at packages\core-runtime.js:138:5
W20250123-13:12:18.297(-6)? (STDERR)     at evaluateNextModule (packages\core-runtime.js:163:14)
W20250123-13:12:18.297(-6)? (STDERR)     at evaluateNextModule (packages\core-runtime.js:202:7)
W20250123-13:12:18.297(-6)? (STDERR)     at runEagerModules (packages\core-runtime.js:206:3)
W20250123-13:12:18.297(-6)? (STDERR)     at processNext (packages\core-runtime.js:128:3)
W20250123-13:12:18.298(-6)? (STDERR)     at packages\core-runtime.js:138:5
W20250123-13:12:18.298(-6)? (STDERR)     at runEagerModules (packages\core-runtime.js:144:12)
W20250123-13:12:18.301(-6)? (STDERR)
W20250123-13:12:18.301(-6)? (STDERR) Node.js v20.18.0
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.

Here’s the packages I currently have. You’ll notice several are turned off.

# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-base@1.5.2             # Packages every Meteor app needs to have
mobile-experience@1.1.1       # Packages for a great mobile UX
#mongo@1.16.10                   # The database Meteor supports right now
#jquery@1.11.10                  # Helpful client-side library
#es5-shim@4.8.0                # ECMAScript 5 compatibility for older browsers.

#aldeed:autoform
#aldeed:collection2
#iron:router
sacha:spin
#twbs:bootstrap
#accounts-password@2.4.0
#underscore@1.6.1
#ejson@1.1.3
#check@1.4.1
#blaze-html-templates
ecmascript@0.16.8
#themeteorchef:jquery-validation
#standard-minifier-css@1.9.2
#kadira:dochead
#shell-server@0.5.0
#dynamic-import@0.7.3
#mdg:meteor-apm-agent

#mdg:seo
#meteorhacks:npm


#npm-container
#http
#mrt:cheerio
#autoupdate@1.8.0
#accounts-ui@1.4.2
#force-ssl@1.1.0
#fetch@0.1.4
core-runtime
mongo
aldeed:simple-schema@2.0.0
jquery
blaze@3.0.0
blaze-html-templates@3.0.0
ostrio:flow-router-extra@3.11.0-rc300.1
aldeed:collection2

shell-server
dynamic-import
check
  • aldeed:collection2 depends on aldeed:simple-schema
  • aldeed:simple-schema exports SimpleSchema

Could you please show how you use SimlpeSchema here: lib/collections/AddedInfo.js:40

Here it is:

AddedInfo.attachSchema(new SimpleSchema({
  carID: {
    label: "Brand Name",
    type: String,
    optional: false,
    max: 100,
    autoform: {
      group: addedInfo,
    }
  }

Check the imports. Double check for typos and that it is from the correct Meteor package and not the old npm import. Sometimes things slip through.

Maybe import SimpleSchema from 'meteor/aldeed:simple-schema'?
I use a self maintained NPM for simpl-schema but I guess that is what the import from a Meteor package would look like

I never had to import packages before migrating. However, I did import simple-schema, but now it’s saying addedInfo is not defined at the following line of code:
AddedInfo = new Mongo.Collection(addedInfo);

new Mongo.Collection() can have 1 or 2 parameters, a string (DB name) or DB name and an object with connection details. If your DB is part of the default connection of your project (e.g. all your MongoDBs are on the same cluster and your app is connected to it via the default MONGO_URL env var) you would probably only use a parameter of type string.

I guess addedInfo is supposed to be a string so you can make it a string instead of a variable.

I started de-globalizing my projects 4-5 years ago. You might be suffering now from just that.

You might be having various variables defined with var or just a name declaration in multiple places in the project and expect to avail of them as global variable while they might not be so global anymore. E.g.

// anywhere
var addedInfo = 'addedInfo' // or some other DB name
// or
addedInfo = 'addedInfo'

Ideally you should ```import { Meteor } from ‘meteor/meteor’ everywhere you use it and similarly you should reduce your reliance on global variables.

Similarly, your mongo declaration should use a const
Maybe have a folder with all schemas as separate files and import schemas from there.

import { Mongo } from 'meteor/mongo'
import { AddedInfoSchema } from './schemas/addedInfo'

const AddedInfo = new Mongo.Collection(addedInfo); // for a name import such as import { AddedInfo }
AddedInfo.attachSchema(AddedInfoSchema)
AddedInfo.createIndexAsync({ field: 1, otherField: -1 })

export default AddedInfo