简体   繁体   English

如何解决错误:ENOENT:没有这样的文件或目录

[英]How to solve Error: ENOENT: no such file or directory

I am brand new at Gatsby and I am currently following this tutorial.我是 Gatsby 的新手,目前正在学习本教程。 https://www.michaeluloth.com/starting-a-new-gatsby-project . https://www.michaeluloth.com/starting-a-new-gatsby-project

When I type in the command 'gatsby develop' everything shows up to be successful.当我输入命令“gatsby develop”时,一切都显示为成功。 Yet in the end, it gives the error:然而最后,它给出了错误:

Error: ENOENT: no such file or directory, open 'C:\users[my_username]\Documents\chrono\my_first_gatsby.cache\json_using-typescript_.json'

Steps I followed:我遵循的步骤:

  1. Open Git bash打开 Git bash
  2. Run npm install --global gatsby-cli运行npm install --global gatsby-cli
  3. Run gatsby --version (this verified that I have the latest gatsby version)运行gatsby --version (这验证了我有最新的 gatsby 版本)
  4. Run cd [directory name]运行cd [directory name]
  5. Run gatsby new my_first_gatsby (created a brand new gatsby default starter-project)运行gatsby new my_first_gatsby (创建了一个全新的 gatsby 默认启动项目)
  6. Run cd my_first_gatsby运行cd my_first_gatsby
  7. Run gatsby develop (expecting a link to gatsby's live local development server but it produces the above error.运行gatsby develop (期望链接到 gatsby 的实时本地开发服务器,但它会产生上述错误。

my local environment is as follows:我的本地环境如下:

 System: 
    OS: Windows 10 10.0.18363 
    CPU: (12) x64 Intel(R) Core(TM) i7-10710U CPU @ 1.10GHz 
  Binaries: <br/>
    Node: 15.3.0 - C:\Program Files\nodejs\node.EXE 
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD 
    npm: 7.0.14 - C:\Program Files\nodejs\npm.CMD 
  Languages: 
    Python: 2.7.15 - /c/Users/ahmed/.windows-build-tools/python27/python 
  Browsers: 
    Chrome: 86.0.4240.198 
    Edge: Spartan (44.18362.449.0) 
  npmPackages: 
    gatsby: ^2.24.47 => 2.24.77 
    gatsby-cli: ^2.12.66 => 2.12.107 
    gatsby-image: ^2.0.39 => 2.4.21 
    gatsby-plugin-anchor-links: ^1.2.0 => 1.2.0 
    gatsby-plugin-feed-mdx: ^1.0.0 => 1.0.1 
    gatsby-plugin-local-search: ^1.1.1 => 1.1.1 
    gatsby-plugin-manifest: ^2.0.29 => 2.4.34 
    gatsby-plugin-mdx: ^1.2.14 => 1.2.46 
    gatsby-plugin-netlify-cms: ^4.3.7 => 4.3.16 
    gatsby-plugin-offline: ^3.2.23 => 3.2.31 
    gatsby-plugin-react-helmet: ^3.0.12 => 3.3.14 
    gatsby-plugin-root-import: ^2.0.5 => 2.0.5 
    gatsby-plugin-sharp: ^2.0.35 => 2.6.42 
    gatsby-plugin-smoothscroll: ^1.2.0 => 1.2.0 
    gatsby-plugin-styled-components: ^3.0.7 => 3.3.14
    gatsby-plugin-typography: ^2.6.0 => 2.6.0
    gatsby-remark-copy-linked-files: ^2.0.11 => 2.3.19
    gatsby-remark-images: ^3.3.9 => 3.3.33
    gatsby-remark-responsive-iframe: ^2.1.1 => 2.4.17
    gatsby-remark-smartypants: ^2.0.9 => 2.3.13
    gatsby-remark-vscode: ^2.1.2 => 2.1.2
    gatsby-source-filesystem: ^2.0.29 => 2.3.34
    gatsby-transformer-sharp: ^2.1.18 => 2.5.17
  npmGlobalPackages:
    gatsby-cli: 2.14.1

Run install your dependencies, clean your cache, and develop your project by:运行安装依赖项,清理缓存,并通过以下方式开发项目:

  • npm install
  • gatsby clean
  • gatsby develop

If the error persists, remove your node_modules , your cache folder, and your package-lock.json and repeat the process.如果错误仍然存在,请删除您的node_modules 、您的缓存文件夹和您的package-lock.json并重复该过程。

In addition, since working with Gatsby on Windows it's a bit tricky, I would recommend installing some other dependencies:此外,由于在 Windows 上使用 Gatsby有点棘手,我建议安装一些其他依赖项:

npm install --global windows-build-tools --vs2015

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM