Meteor 2.0 weird importing issue

I’m building an app with meteor 2.0-beta.4 with
react-meteor-data@2.1.2
"react": "^16.13.1"

App structure

  • file: client/main.jsx:
import { App } from '/imports/ui/App';
  • file: imports/ui/App.jsx:
import { AccountProvider } from '/imports/ui/contexts/account-context.js'
// ...
export const App = () => {
  • file: imports/ui/contexts/account-context.js
import { useTracker } from 'meteor/react-meteor-data'
// ...
export const AccountProvider = (props) => {

Error:

Uncaught Error: Cannot find module '/node_modules/meteor/react-meteor-data/index.js'

Weird solution:

add the importing useTracker file to the App.jsx file (Unused)

  • file: imports/ui/App.jsx:
import { useTracker } from 'meteor/react-meteor-data'
// ...
import { AccountProvider } from '/imports/ui/contexts/account-context.js'

Do you have any better solution? Should I create an issue in github?

it’s something about react Suspense/lazy.
I created a repository at https://github.com/minhna/meteor-2.0-beta.4-react-error

I also created a version with meteor 1.12. It works without any problem.

@captainn, @filipenevola do you have any idea?

There was a mishap with a recent publish - I think we’re up to version react-meteor-data@2.1.4 - try updating and see if it fixes you up.

I tried but I don’t know how to update/install version 2.1.4. Meteor says the last compatible is 2.1.2.
I tried to add --allow-incompatible-update but it didn’t work either.
meteor add react-meteor-data@2.1.4 => it installed 2.1.2
meteor update react-meteor-data --allow-incompatible-update => still 2.1.2

Maybe try meteor reset?

I tried, it doesn’t work. 2.1.2 is the only option.
I tried to create new project and 2.1.2 is still the only option.

Do you have a custom babel resolver set up? The specific error you are getting is odd:

Uncaught Error: Cannot find module '/node_modules/meteor/react-meteor-data/index.js'

Why is it looking in node_modules for a package that starts with meteor/?

Yes, I know, that’s weird. I didn’t do any special. You can check my github repository above.

This looks like an issue with the module system. You’ll probably need to get someone familiar with that to look at this. I don’t think it’s a react-meteor-data issue.

You could try putting a local copy of the react-meteor-data in your packages folder though. Maybe test this PR. :wink:

1 Like

Thank you, I will try the local copy of react-meteor-data idea.

I wonder if this has anything to do with it:

No, probably not. This would only apply if appcache was enabled.