Meteor 1.3:我可以从流星壳导入吗? [英] Meteor 1.3: can I import from the meteor shell?

查看:54
本文介绍了Meteor 1.3:我可以从流星壳导入吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的文件.

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

export default device;

但是,除了将其作为全局变量公开之外,我找不到在 shell 中访问它的方法.

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?

推荐答案

可以从 shell 导入某些符号,具体取决于您的 Meteor 版本.

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

从 Meteor v.1.3-beta.12 开始,可以从 shell require 文件.

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

给定一个位于 client 之外的源目录中的文件(即应该在服务器上可用的东西),带有路径

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

我的/文件/路径/the_file.js

my/file/path/the_file.js

您可以使用

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

(注意 ./ 前缀).

或者,对于包:

require("meteor/my-package");

在浏览器中,你可以require文件和包,例如:

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

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

<小时>

import 语句 - 服务器,Meteor v1.3.3+

从 Meteor v1.3.3 开始,可以使用服务器上的 Meteor shell 中的 import 语句:


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';

这篇关于Meteor 1.3:我可以从流星壳导入吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆