【发布时间】:2020-07-30 21:50:04
【问题描述】:
在使用 gatsby-starter-wordpress-advanced 主题运行 gatsby 构建时遇到问题:
Error: ENOENT: no such file or directory, open 'C:\Users\Tobias\Desktop\Gatsby\gatsby-starter-wordpress-advanced\.template-cache\tmp-\.js'"
我认为这可能是路径的问题。路径应该看起来像:
writing tmp-new-page/ template: open '.template-cache/tmp-new-page.js'
见回购:https://github.com/henrikwirth/gatsby-starter-wordpress-advanced/blob/master/create/utils.js
第 53 行,您找到函数 createPageWithTemplate。我试过 console.log(page.uri) 看看发生了什么。它正确输出文件名。我也试过用 gatsby clean 来清除缓存。这似乎是某种反斜杠问题,路径末尾带有 \ .js 而不是 sample-page.js:
no such file or directory, open 'C:\Users\Tobias\Desktop\Gatsby\gatsby-starter-wordpress-advanced\.template-cache\sample-page\.js'
【问题讨论】:
-
不幸的是 gatsby clean 没有做任何改变......仍然是同样的错误。
-
gatsby-clean删除 .cache,但不是 .template-cache,据我所知。您是否尝试在再次运行之前手动删除它并重新安装您的依赖项 (rm -rf node_modules && yarn)? -
不幸的是仍然是同样的错误。我删除了 .template-cache 文件夹和 node_module 文件夹并运行了 npm install。
-
很抱歉听到这个消息 - 您是否关注了 starter you're trying to use 所附的 tutorial?如果你这样做了,你可能想在初学者的 repo 上打开一个问题,因为这个问题似乎非常具体。或者,您可以在 Gatsby Starter Library 上查看其他入门者
-
谢谢,罗宾。我刚刚浏览了博客文章教程的评论部分,似乎我不是唯一一个有问题的人:dev.to/ibjorn/comment/kj14 - 我会在初学者的 repo 上打开一个问题 :)
标签: reactjs wordpress path graphql gatsby