在Meteor中使用fs模块获取Uncaught TypeError _fs2.default.readFile不是函数

嗨,我想在我的Meteor项目中testingFS模块。 我正在使用Meteor 1.3新的es2015模块。 我正在尝试使用节点FS模块来读取文件。 尝试了几个方法,但似乎得到这个相同的错误,当我在浏览器中运行myFunc()。

Uncaught TypeError:_fs2.default.readFile不是函数

import fs from 'fs' myFunc = function(){ fs.readFile('input.txt', function(err, data){ if(err) console.log("Error" + err) console.log("Data from input" + data) }) } 

我认为你不能在浏览器中使用fs模块。 在浏览器中有一个独立的npm模块,称为fs-web 。 在使用npm install fs-web --save之后,可以通过在客户端文件中导入它来使用它,

  import * as fs from 'fs-web';