Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use it on ReactJs , #925

Closed
vishwasrj opened this issue Sep 21, 2016 · 9 comments
Closed

Cannot use it on ReactJs , #925

vishwasrj opened this issue Sep 21, 2016 · 9 comments

Comments

@vishwasrj
Copy link

vishwasrj commented Sep 21, 2016

# creating a simple winston variable and calling the log function from it shows the errors bellow

ERROR in ./~/winston/lib/winston/common.js
Module not found: Error: Cannot resolve module 'fs' in
ERROR in ./~/pkginfo/lib/pkginfo.js
Module not found: Error: Cannot resolve module 'fs' in <filepath>
ERROR in ./~/winston/lib/winston/transports/file.js
Module not found: Error: Cannot resolve module 'fs' in
@danieleleoni
Copy link

Same issue here!

@ultrafez
Copy link

fs is a Node module, so you'll need to use webpack or browserify which should polyfill it.

@bradisbell
Copy link

Using webpack... no polyfill for fs (which makes sense when you think about it... unless it were completely stubbed).

I get the following with Webpack:

WARNING in ./~/winston/lib/winston/transports.js
Critical dependencies:
23:17-34 the request of a dependency is an expression
 @ ./~/winston/lib/winston/transports.js 23:17-34

WARNING in ./~/colors/lib/colors.js
Critical dependencies:
127:29-43 the request of a dependency is an expression
 @ ./~/colors/lib/colors.js 127:29-43

WARNING in ./~/colors/lib/extendStringPrototype.js
Critical dependencies:
106:31-45 the request of a dependency is an expression
 @ ./~/colors/lib/extendStringPrototype.js 106:31-45

ERROR in ./~/winston/lib/winston/common.js
Module not found: Error: Cannot resolve module 'fs' in /vagrant/node_modules/winston/lib/winston
 @ ./~/winston/lib/winston/common.js 12:9-22

ERROR in ./~/pkginfo/lib/pkginfo.js
Module not found: Error: Cannot resolve module 'fs' in /vagrant/node_modules/pkginfo/lib
 @ ./~/pkginfo/lib/pkginfo.js 8:9-22

ERROR in ./~/winston/lib/winston/transports/file.js
Module not found: Error: Cannot resolve module 'fs' in /vagrant/node_modules/winston/lib/winston/transports
 @ ./~/winston/lib/winston/transports/file.js 10:9-22

@bradisbell
Copy link

If I use node: { fs: 'empty' } in my webpack.config.js, the errors go away (I'm left with the warnings), but the script doesn't work. Calls to try to read pkginfo are being made.

@shawnxusy
Copy link

@bradisbell I'd guess you are importing the winston in a browser environment, which winston is not supporting right now (see #582).
Even if you think your winston is imported in a server-only file (let's say logger.js), make sure to check that logger.js is not imported into another file used by webpack browser build. It is common that this happens with universal rendering.
In short, winston stays in Node only.

@jeanabraham
Copy link

@bradisbell, also see #287. I'm looking for something similar. Curious to know if you found anything that did the trick for you?

@bradisbell
Copy link

@jeanabraham I just wrote my own. The core functionality of Winston can be replicated quite quickly.

@indexzero
Copy link
Member

Yes, this is a duplicate of #287. After winston@3.0.0 ships adding proper browser support is the next thing on our ROADMAP.

If you're interested in contributing to this effort please let me know and I can help you get involved!

@moffsugita
Copy link

TypeError: fs.stat is not a function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants