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

TypeError: fs$ReadStream is undefined #121

Closed
saadb opened this issue Dec 12, 2017 · 8 comments
Closed

TypeError: fs$ReadStream is undefined #121

saadb opened this issue Dec 12, 2017 · 8 comments

Comments

@saadb
Copy link

saadb commented Dec 12, 2017

using graceful-fs version 4.1.11 in create-react-app with "react-scripts": "1.0.17"

The error above is reported when I run yarn start

./node_modules/graceful-fs/graceful-fs.js:166

163 | }
164 |
165 | var fs$ReadStream = fs.ReadStream

166 | ReadStream.prototype = Object.create(fs$ReadStream.prototype)
167 | ReadStream.prototype.open = ReadStream$open
168 |
169 | var fs$WriteStream = fs.WriteStream

./node_modules/configstore/node_modules/graceful-fs/graceful-fs.js
24 | })
25 | }
26 |

27 | module.exports = patch(require('./fs.js'))
28 | if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH) {
29 | module.exports = patch(fs)
30 | }

./node_modules/configstore/node_modules/graceful-fs/graceful-fs.js

1 | var fs = require('fs')
2 | var polyfills = require('./polyfills.js')
3 | var legacy = require('./legacy-streams.js')
4 | var queue = []

Please investigate, why is happening?

@Hertox82
Copy link

same issue

@anonymous0374
Copy link

fs does not have ReadStream method.

tried on:
nodejs: v8.3, v8.4, v9.4
node-graceful-fs and webpack are of the latest versions

in nodejs v9.4 api documentation, fs object does have ReadStream method, is the fs required in node-graceful-fs the same fs in nodejs?

could someone give a hand?

@anonymous0374
Copy link

I bypassed this error by adding these last two lines(comment with "fix"), any risks underneath?
thank you
@isaacs
selection_008

@anonymous0374
Copy link

OK, my mistake. I should use node-graceful-fs in a nodejs environment, instead of in browser via webpack.
I'm setting up a rest api with expressjs to do this(in order to communicate with mongodb server).

@AnelaNuo
Copy link

Dear Isaacs,
Could you close issues #109 and this after fixing this bug.
I tried to rewrite two last lines in your code by the above pattern in my local node_modules and solved this problem in React app.
But I finded this precription for a long time, because no one issues not closed.

Best regards, Anela.

@spirosbax
Copy link

Here is how I fixed it:

  • replace fs.ReadStream with fs.createReadStream in line 165,
  • replace fs.WriteStream with fs.createWriteStream in line 169,

this works because in the docs there are create methods for creating streams.

@sumit6b
Copy link

sumit6b commented Nov 27, 2018

@spirosbax was trying your solution but got this error:

Uncaught TypeError: Cannot read property 'require' of undefined
at Proxyquire../node_modules/graceful-ncp/node_modules/proxyquire/lib/proxyquire.js.Proxyquire.load

@coreyfarrell
Copy link
Collaborator

This issue should be resolved by latest graceful-fs. Please let us know if you continue to have problems after updating.

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

7 participants