[SOLVED] Cannot read property 'uid'

Hello everyone. This project worked fine a few months ago. Now, project unchanged, it crashes. I am not sure how to resolve this. Does anyone else have any ideas? It’s great that ‘uid’ is undefined, but where? How? Another error message I do not even know where to start with…

Yes, I updated Meteor, and yes, I updated npm. Details below.

davidlogan@DAVIDs-MBP-2 v2iccserver % meteor run         
exec /Users/davidlogan/.meteor/meteor run
[[[[[ ~/workspace/icc/v2iccserver ]]]]]       

=> Started proxy.                             
=> Started MongoDB.                           
=> Errors prevented startup:                  
   
   While building for web.browser:
   client/main.tsx: /Users/davidlogan/workspace/icc/v2iccserver/client/main.tsx: Cannot read property 'uid' of undefined
   
   While building for web.browser.legacy:
   client/main.tsx: /Users/davidlogan/workspace/icc/v2iccserver/client/main.tsx: Cannot read property 'uid' of undefined
   
   While building for web.cordova:
   client/main.tsx: /Users/davidlogan/workspace/icc/v2iccserver/client/main.tsx: Cannot read property 'uid' of undefined
   
   While building for os.osx.x86_64:
   imports/server/Game.js: /Users/davidlogan/workspace/icc/v2iccserver/imports/server/Game.js: Cannot read property 'uid' of undefined
   imports/collections/i18n.js: /Users/davidlogan/workspace/icc/v2iccserver/imports/collections/i18n.js: Cannot read property 'uid' of undefined
   imports/collections/users.js: /Users/davidlogan/workspace/icc/v2iccserver/imports/collections/users.js: Cannot read property 'uid' of undefined
   imports/server/Chat.js: /Users/davidlogan/workspace/icc/v2iccserver/imports/server/Chat.js: Cannot read property 'uid' of undefined
   imports/server/GameRequest.js: /Users/davidlogan/workspace/icc/v2iccserver/imports/server/GameRequest.js: Cannot read property 'uid' of undefined
   imports/server/DynamicRatings.js: /Users/davidlogan/workspace/icc/v2iccserver/imports/server/DynamicRatings.js: Cannot read property 'uid' of undefined
   imports/startup/server/firstRunCss.js: /Users/davidlogan/workspace/icc/v2iccserver/imports/startup/server/firstRunCss.js: Cannot read property 'uid' of undefined
   imports/startup/server/firstRunClientInternationalization.js: /Users/davidlogan/workspace/icc/v2iccserver/imports/startup/server/firstRunClientInternationalization.js: Cannot read property 'uid' of undefined
   imports/server/EcoSchema.js: /Users/davidlogan/workspace/icc/v2iccserver/imports/server/EcoSchema.js: Cannot read property 'uid' of undefined
   
=> Your application has errors. Waiting for file change.
^C                                            
davidlogan@DAVIDs-MBP-2 v2iccserver % meteor list ; npm list
exec /Users/davidlogan/.meteor/meteor list
accounts-password                 2.2.0  Password support for accounts
alanning:roles                    3.4.0  Authorization package for Meteor
aldeed:collection2                3.5.0  Automatic validation of Meteor Mongo insert and update operations on the client and server
dburles:factory                   1.1.0  Factories for Meteor
ecmascript                        0.16.1  Compiler plugin that supports ES2015+ in all .js files
es5-shim                          4.8.0  Shims and polyfills to improve ECMAScript 5 support
http                              1.4.4* Make HTTP calls to remote servers
hwillson:stub-collections         1.0.9  Stub out Meteor collections with in-memory local collections.
johanbrook:publication-collector  1.1.0  Test a Meteor publication by collecting its output.
lmieulet:meteor-coverage          3.2.0* Server and client coverage for Meteor
mdg:validated-method              1.2.0  A simple wrapper for Meteor.methods
meteor-base                       1.5.1  Packages that every Meteor app needs
meteorhacks:picker                1.0.3  Server Side Router for Meteor
meteortesting:mocha               2.0.3  Run Meteor package or app tests with Mocha
mizzao:user-status                1.0.1  User connection and idle state tracking for Meteor
mobile-experience                 1.1.0  Packages for a great mobile user experience
mongo                             1.14.6  Adaptor for using MongoDB and Minimongo over DDP
omega:json-protocol               1.0.1  JSON protocol to send arbitrary data over Meteor's websocket
ostrio:files                      2.0.1  Upload files to Meteor application, with 3rd party storage support: AWS:S3, GridFS and other
patelutsav:meteor-migrations      0.0.6  Simple migration system for Meteor based on string version number.
react-meteor-data                 2.4.0  React hook for reactively tracking Meteor data
reactive-dict                     1.3.0  Reactive dictionary
reactive-var                      1.0.11  Reactive variable
reywood:publish-composite         1.7.3  Publish a set of related documents from multiple collections with a reactive join
shell-server                      0.5.0  Server-side component of the `meteor shell` command.
standard-minifier-css             1.7.4  Standard css minifier used with Meteor apps by default.
standard-minifier-js              2.8.0  Standard javascript minifiers used with Meteor apps by default.
static-html                       1.3.2  Define static page content in .html files
tracker                           1.2.0  Dependency tracker to allow reactive callbacks
typescript                        4.4.1  Compiler plugin that compiles TypeScript and ECMAScript in .ts and .tsx files
ultimatejs:tracker-react          1.0.5  No-Config reactive React Components with Meteor. Apply as composition, mixin or decorator.
universe:i18n                     1.32.6  Lightweight i18n, YAML & JSON translation files, React component, incremental & remote loading
xolvio:cleaner                    0.4.0  Gives you methods to clear your Mongo database and collections for testing purposes

                                              
* New versions of these packages are available! Run 'meteor update' to try to update those packages to their latest versions. If your packages cannot be updated further, try typing `meteor add <package>@<newVersion>` to see
  more information.
icc@0.2.3 /Users/davidlogan/workspace/icc/v2iccserver
├── @babel/plugin-proposal-class-properties@7.16.7
├── @babel/plugin-proposal-decorators@7.17.2
├── @babel/preset-env@7.16.11
├── @babel/preset-react@7.16.7
├── @babel/runtime@7.17.7
├── @chess-fu/fen-parser@1.1.4
├── @chessclub.com/chesspgn@1.0.10
├── @chessclub.com/legacy@1.0.4
├── @types/chai@4.3.0
├── @types/meteor@1.4.87
├── @types/react-dom@17.0.13
├── @types/react@17.0.40
├── @typescript-eslint/eslint-plugin@5.15.0
├── @typescript-eslint/parser@5.15.0
├── @wojtekmaj/enzyme-adapter-react-17@0.6.6
├── add-font@1.0.2
├── antd@4.19.2
├── async@3.2.3
├── aws-sdk@2.1094.0
├── axios@0.19.2
├── babel-eslint@10.1.0
├── babel-plugin-direct-import@0.6.4
├── babel-plugin-istanbul@6.1.1
├── babel-plugin-lodash@3.3.4
├── babel-plugin-transform-es2015-modules-commonjs@6.26.2
├── bcrypt@5.0.1
├── chai-as-promised@7.1.1
├── chai@4.3.6
├── chess.js@0.12.1
├── chessboard@1.0.0 (git+ssh://git@github.com/chessclub/v2icc-chessboard.git#7d1b4889837accddfb7cd75c61f0b76c0ca45c1f)
├── classnames@2.3.1
├── create-react-class@15.7.0
├── date-and-time@1.0.1
├── dotenv@8.6.0
├── enzyme@3.11.0
├── eslint-config-prettier@8.5.0
├── eslint-config-react-app@6.0.0
├── eslint-plugin-flowtype@5.10.0
├── eslint-plugin-import@2.25.4
├── eslint-plugin-jsx-a11y@6.5.1
├── eslint-plugin-meteor@7.3.0
├── eslint-plugin-prettier@3.4.1
├── eslint-plugin-react-hooks@4.3.0
├── eslint-plugin-react@7.29.4
├── eslint@7.32.0
├── faker@5.5.3
├── indexof@0.0.1
├── is-whitespace-character@2.0.1
├── jest@26.6.3
├── jsdom@16.7.0
├── lodash@4.17.21
├── meteor-node-stubs@1.2.0
├── moment@2.29.1
├── moo@0.5.1
├── mup@1.5.7
├── prettier@2.6.0
├── prop-types@15.8.1
├── puppeteer@9.1.1
├── react-addons-pure-render-mixin@15.6.3
├── react-avatar-edit@1.1.0
├── react-color@2.19.3
├── react-dom@17.0.2
├── react-jss@10.9.0
├── react-router-dom@5.3.0
├── react-test-renderer@17.0.2
├── react@17.0.2
├── redux@4.1.2
├── rollup@1.32.1
├── simpl-schema@1.12.0
├── sinon@10.0.0
├── slack-notify@0.1.7
├── tunnel-ssh@4.1.6
└── typescript@4.6.2

davidlogan@DAVIDs-MBP-2 v2iccserver % 

you should start with the first line: client/main.tsx

1 Like

I have no idea what this means. Was it supposed to be helpful? Here are the first six lines of client/main.tsx:

import { Meteor } from "meteor/meteor";
import { render } from "react-dom";
import React from "react";
import "../lib/client/timestamp";
import { Logger } from "../lib/client/Logger";
import { current_release } from "../imports/startup/release";

And again, why did this work fine in December? Yes, we have another meteor project we are working on (kind of replacing this one, actually), so it’s got to be some type of discrepancy between meteor files from then and now.

That’s fine, I just do not know with this little bit of error message even where to start with this.

you must find in code lines contains .uid then try to trace back, you may find the real issue.

No help of course.

However, I tinkered with various combinations of ‘rm .meteor’, ‘npm install’, ‘rm -Rf node_modules’, ‘meteor npm install’ and ‘git rollback’ over and over and over, and finally something cleared up. No explanation for it. I have no idea what it was complaining about or why it cleared up.

I think the moral of this story really is that we REALLY need better error messages. The vast majority of error messages coming out of javascript, node, and Meteor are just unhelpful without a bunch of research.

Anyway, whatever sunspots caused this issue yesterday seems to have cleared up.

1 Like

this is not per-se a meteor problem. Read the error message, that is a really common error.

You are accessing the property uid on something that is undefined.

so look for something.uid. something is undefined.

This project worked fine a few months ago. Now, project unchanged, it crashes.

You did not share a useful code snippet, so its hard to tell what the underlying problem is. But i would guess that its data-related. So while the app did not change, something i the data changed. Could also be a timing problem.

This project is not accessing or using anything in any way that uses a “uid” property. Zero. Nothing. Nada.

Since I repulled from git and reran npm install, I suspect there was some incompatibility between npm modules or maybe meteor modules. I don’t know.

By the way, that’s why I did not share any “useful code snippet.” It’s not my code. It was 100% in the build, and I will say again, from a project that was built and running in production already! All I did was go get it and try to rebuild it.

Anyway, it’s fine that it’s a library incompatibility, but this isn’t the first time I have ran across error messages that provide no real useful information. It’s pretty common.

Whatever it was, it magically disappeared with various npm and meteor reinstalls, so I am just going to let it drop here.

Thank you.

1 Like

Have the same issue. Suddenly my app doesn’t build on one linux machine, which was always working. However don’t have time right now to look further into it.

My gut feeling is that it has something to do with babel

There’s something wrong with bumped dependencies. I restored to the previous package-lock.json version and did npm ci and then it started building again.

Didn’t track down which package exactly is causing the problem.

1 Like

I’m facing the same issue while migrating a React app to Next.js: even in this case, there’s no trace of .uid anywhere in the code. Did you found where the problem was? Which precise library had you rolled back to override this issue?
Thank you

We encountered this problem and it was related to babel-plugin-direct-import

Oh, got the same error today. In our case it was caused by babel-plugin-inline-react-svg. Did you try to remove each import step by step to check which one causes the issue in your code?

Yes. We only have a few, so it was an easy find. In our case, the error happens only if the babel plugin is added but not used. When there is a case that it is in use, there is no error.