Register now - Learn how Tecovas roped in success with Sanity and Shopify 🀠

Error when adding gatsby-source-sanity plugin due to existing gatsby-node.ts file.

20 replies
Last updated: Jul 20, 2020
have used sanity on a few projects, but this is the first project im using it on where I have made the gatsby core files ts (gatsby-node etc) I get this error when adding

ENOENT: no such file or directory, open '/Users/isaacmartin/Documents/code/tm-landing/web/node_modules/gatsby-source-sanity/src/gatsby-node.ts'
Jul 15, 2020, 7:10 PM
sure this is something in the fact that i already have a
Jul 15, 2020, 7:20 PM
anyone seen this before?
Jul 15, 2020, 7:20 PM
Hi Isaac, could you try removing your
folder and `yarn.lock`/`package-lock.json` files before running
npm install
to see if that changes anything?
Jul 15, 2020, 9:49 PM
[In your studio root folder]
Jul 15, 2020, 9:49 PM
hey peter, yeah still the same issue
Jul 16, 2020, 3:05 PM
worth noting as well removing the plugin from config array means the error is no longer there as expected (but we obviously can't source data then)
Jul 16, 2020, 3:06 PM
also manually moving the gatsby-node.ts into a src directory in
silences the error but it then doesn't source any data
Jul 16, 2020, 3:47 PM
Wonder if there needs to be a flag or something in the plugin if using TS to resolve correctly?
user M
Jul 17, 2020, 1:13 PM
Im happy to PR this if someone gives me some guidane 😬
Jul 17, 2020, 1:14 PM
Not sure why this is not getting picked up correctly. I’ll ask internally as well to see if someone better versed than me in TS knows why this could be happening πŸ™‚
Jul 17, 2020, 1:28 PM
Thanks Peter
Jul 17, 2020, 1:30 PM
I've converted gatsby core-files to ts in a project I'm working on, works like a charm. Maybe our code could be of some help to you (tho there will be norwegian comments πŸ˜›):
Jul 20, 2020, 10:37 AM
user Q
- did you ever see this error message?
Jul 20, 2020, 1:19 PM
nope, dont remember having any trouble with gatsby-source-sanity when converting to ts πŸ€”
Jul 20, 2020, 1:52 PM
Damn 😞
Jul 20, 2020, 1:56 PM
must be something else going on
Jul 20, 2020, 1:56 PM
Do you have any public/private repo you could share in this case (in DM if you prefer)?
Jul 20, 2020, 1:57 PM
Update - resolved. not related to ts. I had a spelling mistake in my env variable name
Jul 20, 2020, 4:13 PM
Might need the error message to be updated to say thats the reason its not working
Jul 20, 2020, 4:13 PM
Indeed, no way to know that through the error message πŸ™‚ Happy you can move ahead with TS!
Jul 20, 2020, 4:33 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?

Categorized in