Uncaught TypeError: fs.readdirSync is not a function
I'm building a Meteor 1.3 app and I'm getting this error when I add import the googleapis node package into my client side React component:
Uncaught TypeError: fs.readdirSync is not a function
It looks like it's coming from this code block in the package:
fs.readdirSync(path.join(__dirname, '../apis')).forEach(function (file) {
apis[file] = requireAPI('../apis/' + file);
});
I'm importing the package using:
import google from 'googleapis';
Is this because fs is a server side package and doesn't work on the client?
Can I use this package on the client side in the browser?
Thanks!
This library (google-api-nodejs-client) will not work in the browser, only in Node.js.
Hey guys I'm getting the same error but on server. For example if I want to export a function then it would throw 'Uncaught TypeError: fs.readdirSync is not a function'. This is caused by 'import google from 'googleapis';'
for example
test1.js >
import google from 'googleapis'; export function hello(){}
test2.js
import {hello} from './test1.js'
this will throw the error. Function is being exported and imported (used) on the server.