Closed ryanab00 closed 9 months ago
This is a problem with your vue app. Do note that fs
doesn't work in a browser, so anything client-rendered can't read from the filesystem.
This is a problem with your vue app. Do note that
fs
doesn't work in a browser, so anything client-rendered can't read from the filesystem.
So I have to read it in a separate file first? Even so, won't the error in the module still persist?
I can't speak to how your types are set up, but yes, you have to read it on the server.
Since this isn't a node question - more of a vue and typescript question - I'm going to close this.
As I said it's a fresh install, it shouldn't have any errors in the module, implementation of it isn't what I am focusing on.
Node.js does not publish its own types. The @types/node
you installed, of which fs.d.ts is a part, is instead created by the community at DefinitelyTyped. If you found errors in that package, please report them there, as there is nothing that can be done here.
ok, but that's still not a problem with node, it's a problem with the types for the module, or with vite, or with vue.
I see, thanks for the help.
Version
v19.9.0
Platform
Microsoft Windows NT 10.0.19045.0 x64
Subsystem
No response
What steps will reproduce the bug?
Simply create a new vite with typescript enviorment.
How often does it reproduce? Is there a required condition?
I created two separate environments to make sure I didn't add anything to break it, or if I was using it improperly, but the error is shown right from the start of each of these applications, meaning I haven't added anything to them yet, they are just the base template from npm.
What is the expected behavior? Why is that the expected behavior?
fs should be able to be imported and used, but it is not recognized as a function. Upon further inspection there is an error with the node module itself.
What do you see instead?
After adding a txt file to the assets folder, and running a simple function to test the FileReader, error shows saying fs is not a function. This is most likely due to the error in the module itself.
Additional information
Not sure if I did anything wrong, or if my test function implementation is incorrect. If anyone can help me with this that would be greatly appreciated.