MeteorJS意外的令牌导入

时间:2018-02-18 16:24:50

标签: meteor ecmascript-6 babel

我正在尝试编写一个Meteor包。我首先使用meteor create myappcd创建了一个流星应用程序到项目根目录中,然后meteor create --package mypkg。这生成了基础包锅炉文件。在mainmodule条目JS文件中,我写了

if (Meteor.isServer) {
    require('./server/main.js');
}

if (Meteor.isClient) {
    require('./client/main.js');
}

client/main.js我写了

import { Meteor } from 'meteor/meteor';

当我使用meteor

运行应用程序时,这会导致错误
W20180219-00:13:14.495(8)? (STDERR) import { Meteor } from 'meteor/meteor';
W20180219-00:13:14.495(8)? (STDERR) ^^^^^^
W20180219-00:13:14.496(8)? (STDERR) 
W20180219-00:13:14.496(8)? (STDERR) SyntaxError: Unexpected token import
W20180219-00:13:14.496(8)? (STDERR)     at createScript (vm.js:80:10)
W20180219-00:13:14.496(8)? (STDERR)     at Object.runInThisContext (vm.js:139:10)
W20180219-00:13:14.496(8)? (STDERR)     at /home/user/Documents/GitHub/meteor-accounts-solutions/.meteor/local/build/programs/server/boot.js:393:30
W20180219-00:13:14.496(8)? (STDERR)     at Array.forEach (<anonymous>)
W20180219-00:13:14.496(8)? (STDERR)     at /home/user/Documents/GitHub/meteor-accounts-solutions/.meteor/local/build/programs/server/boot.js:220:19
W20180219-00:13:14.496(8)? (STDERR)     at /home/user/Documents/GitHub/meteor-accounts-solutions/.meteor/local/build/programs/server/boot.js:471:5
W20180219-00:13:14.497(8)? (STDERR)     at Function.run (/home/user/Documents/GitHub/meteor-accounts-solutions/.meteor/local/build/programs/server/profile.js:510:12)
W20180219-00:13:14.497(8)? (STDERR)     at /home/user/Documents/GitHub/meteor-accounts-solutions/.meteor/local/build/programs/server/boot.js:470:11
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.

我已在package.js

中添加了以下几行
api.versionsFrom('1.6.1');
    api.use([
        'ecmascript',
        'es5-shim',
        'babel-runtime'
    ]);

任何帮助表示赞赏。如果我要发布更多代码,请告诉我,谢谢。

0 个答案:

没有答案