I am having some trouble importing a module into the meteor shell.
Steps I follow are from the Meteor Tuts, right at the beginning:
create new project (meteor create myproject)
create file /imports/api/donuts/collection.js and paste content:
// file: /imports/api/donuts/collection.js
import { Mongo } from 'meteor/mongo';
const Donuts = new Mongo.Collection('donuts');
export default Donuts;
3, Run meteor shell and import the file by:
import Donuts from '/imports/api/donuts/collection.js'
than this error hits up:
Error: Cannot find module '/imports/api/donuts/collection.jsā
at Function.require.resolve (packages/modules-runtime.js:129:19)
at Module.resolve (packages/modules-runtime.js:81:25)
at Module.Mp.import (/home/ec2-user/.meteor/packages/modules/.0.7.7.mccaq7++os+web.browser+web.cordova/npm/node_modules/reify/lib/runtime.js:61:29)
at repl:1:-37
at packages/shell-server/shell-server.js:458:25
at /home/ec2-user/.meteor/packages/promise/.0.8.8.i94065++os+web.browser+web.cordova/npm/node_modules/meteor-promise/fiber_pool.js:32:39
Whatās wrong? File permissions are ok, I start the meteor shell from project root.
Hi. I am the creator of Meteor-Tuts and shame on me!
In my defence I only advertised it here and I specifically said it was not ready yet, itās just a beta. But Iām glad it spread out
Your feedback is great! Basically what you need to do, is your Meteor needs to be aware of that collection first. Otherwise it will not load everything by default
Go to /imports/startup/server/index.js. And just do :
import Donuts from '/imports/api/donuts/collection.js'
It will work. Today Iām finalizing the tutorial, and testing everything.
I am trying to get more familiar with the meteor shell, reason why I was following your tuts. I was so enthusiastic about working with imports inside the shell without including them elsewhere, but it turns out this step canāt be overcome.
So itās still need to include the collection.js in server/main.js. I am wondering why is the meteor shell bound to the process only, and not the whole project?
Hehe, I knew this would be an issue, I am now rewriting it to make it even more simple and introduce āNasty Globalsā, so we can use globals just for testing, Iāll put a big disclaimer discouraging it
The reason is that Meteor compiles files it needs to know about, not everything. So if you never imported it anywhere, it wonāt be available in Meteor shell.
I will update soon the tuts, to make it even more friendly for beginners. Will let you know here!