-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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 resolve module 'fs' #564
Comments
In Webpack, In 1.0 with GraphQL you'll be able to write GraphQL queries in your components to pull in the data you want from the JSON files. In 0.x, you'll want to preprocess the data and write it out to the |
|
Was this solved? Have the same issue and its driving me cr...!!! |
@hausinho make sure you're not importing code that tries to use the |
So i'm most likely completely off here... I thought the benefit of Gatsby was running your code on the server ... so why wouldn't your node server have access to fs? |
@alxvallejo you're a bit off. Gatsby runs on the server, all of the code is generated beforehand and sent to you and then rehydrated on the client. That's one of the gatsby's key features.
|
Just in case you're getting this, the following fixes it for me: // gatsby-node.js
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
node: {
fs: 'empty'
}
})
} |
Thanks, @lucalanca ! That fixed it for me. :-) (I had to add |
@lucalanca Thanks so much this helped me a lot was starting to get crazy :) |
thanks @lucalanca your solution fixed my issue.. |
In case someone still needs this and is getting the warning below:
This helped me: exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
resolve: {
fallback: {
fs: false,
},
},
});
}; |
I have a directory (
/data/
) of files that follow the general format ofThat's a simple example, in reality each file is an object containing many keys. I initially had one single JSON file that I imported an used, but the more items that I added, the harder it got to maintain in raw text. So I created the directory structure, and then made an entry point that looks like this:
And outside of gatsby, this works as expected, I can simply
import * as data from './dataInporter'
and then inside ofdata.default
contains an array of the objects. Unfortunately in Gatsby I getIs there any way you can think of to work around this?
As an aside, there is likely a better way to do what I'm trying to do, I'm open to input on that as well.
The text was updated successfully, but these errors were encountered: