This worked fine in 1.3.2, however since I’ve upgraded to 1.3.3 I get the following error:
Unable to resolve some modules:
"/Users/josh/Projects/CLIENT/codebase/lib/collections" in /Users/josh/Projects/CLIENT/codebase/client/configs/context.js (web.browser)
Likewise on the server:
Unable to resolve some modules:
"/Users/josh/Projects/CLIENT/codebase/lib/collections" in /Users/josh/Projects/CLIENT/codebase/server/publications/file_name.js (os.osx.x86_64)
Not sure I can answer your question, but I can shed light on the “./” notation. That is forming a reference relative to the current directory. So, on the client side “./lib/collections” is asking it to look for /Users/josh/Projects/CLIENT/codebase/client/configs/lib/collections.
So is /lib/collections a directory with an “index.js”? If not and it is actually an attempt to reference /lib/collections.js, did you try adding “.js” to the initial example? It seems like I had a problem where I had left some “.js” extensions off and it worked for a while and then stopped. I just added the extensions without thinking about it. I’ve been using the development branches for Meteor 1.4 for a while, so I may have hit the problem you’re encountering when I switched without consciously realizing it.
I also faced the same issue. So to fix it I had to go through all the files and change the paths. All the paths relative to the root of the project have to be changed to be relative to the directory where the file is in. So, this : import * as Collections from '/lib/collections'; had to be re-written to this : import * as Collections from '../../lib/collections';
Thanks for the tip @rlivingston Anyway, any idea why it’s happening?
It seems like a bug to me. You should be able to import your file using import * as Collections from '/lib/collections';, but somehow meteor thinks you mean the filesystem root instead of your project root.
FYI, I think this may be a different manifestation of meteor issue #7221. It appears to be a Windows specific problem. I’d bet they are fast at work on 1.3.3.1.
Also, note that absolute paths that relate to the project’s root directory are very definitely supported. I spent some time yesterday looking at the Meteor tool test code and found that the very first test in their modules test package checks whether an absolute path works.
I just updated to the latest version of babel-root-slash-import but still the problem is there And also noticed that the tests fail even with that plugin. Looks like the tests can’t find mongo Error: Cannot find module 'meteor/mongo'.
@lcpubs That’s true. We are using pure node based testsing. It can’t understand meteor imports.
In mantra, we write code to avoid Meteor imports. All the meteor imports should go inside the app context file.
Ah thanks… Any idea why the tests are failing and why adding babel-root-slash-import (The latest version) gives an error on missing modules? Those are not meteor imports
The import issue is fixed No idea what happened but after updating meteor again, it worked. But the tests still fail regardless of the root slash plugin. The thing is, they work in the sample blog app (With my meteor version). There might be something wrong with my project. But no idea what. Need to find out before opening a ticket! Anyway thanks for the help!