简体   繁体   English

流星1.3模块-如何在控制台中使用npm导入的库?

[英]Meteor 1.3 modules - how to use npm imported libraries in the console?

I'm using Meteor 1.3 with ES32015 modules and native npm support, and I'm using momentjs from npm: 我正在使用带有ES32015模块和本机npm支持的Meteor 1.3,并且正在使用npm中的momentjs:

import moment from 'moment';

It all works fine in the project, but when I want to test out moment in the console, it says that it's undefined . 在项目中一切正常,但是当我想在控制台中测试moment时,它表示undefined Can I somehow import in the runtime? 我可以以某种方式导入运行时吗?

Use import moment from 'moment'; import moment from 'moment';使用import moment from 'moment';

Make sure you are putting () to the imported module. 确保将()放入导入的模块。

console.log(moment());

var moment = require('moment')()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM