How to use node's fs module in 1.3


In a attempt to migrate my app to Meteor 1.3 i ran into problems using the fs package to use fs.createReadStream in my test code (server-only).

I tried to use:
import fs from ‘fs’; and
import * as fs from ‘fs’;

with and without meteor-node-stubs, but I got only a minimal fs-object with four functions:
fs: { existsSync: [Function: existsSync],
readdirSync: [Function: readdirSync],
statSync: [Function: statSync],
watchFile: [Function: watchFile]}

Can someone tell me what i am doing wrong?
Thanks in advance, m.


const fs = require('fs');

Try that one. Works for my code to save uploaded files to disk.


Thanks. Following your suggestion I still got an object with only those four functions when using it in my .test.js files. But knowing that it works for you, I tried it directly in my server code and there it worked fine…

So my suspicion is, that my import problem has something to do with running in test-mode (
meteor test --driver-package practicalmeteor:mocha).

Thx, m.