corvid
corvid

Reputation: 11197

Meteor 1.3: can I import from the meteor shell?

I have a file like this.

const device = new Device({
  host: process.env.GALIL_HOST,
  port parseInt(process.env.GALIL_PORT, 10)
});

export default device;

However, I cannot find a way to access this in the shell, other than to expose it as a global variable.

Is there any way to import from the meteor shell?

Upvotes: 3

Views: 927

Answers (1)

MasterAM
MasterAM

Reputation: 16488

It is possible to import certain symbols from the shell, depending on your Meteor version.


require() - client and server, Meteor v1.3+

As of Meteor v.1.3-beta.12, it is possible to require files from the shell.

Given a file in a source directory other than client (i.e, something that should be available on the server), with the path

my/file/path/the_file.js

You can get an object that contains your exports using

require('./my/file/path/the_file.js');

(note the ./ prefix).

or, for packages:

require("meteor/my-package");

In the browser, you can require files and packages, for example:

const { Match, check } = require('meteor/check');

import statements - server, Meteor v1.3.3+

Starting with Meteor v1.3.3, it is possible to use import statements from the Meteor shell on the server:

import { Match, check } from 'meteor/check';

Upvotes: 10

Related Questions