开发第一个gatsby项目时报错11903

Error 11903 when developing first gatsby project

我正在尝试建立我的第一个 Gatsby 网站。在 运行ning npm install -g gatsby-cli 之后,我 gatsby new gatsby-starter-hello-world https://github.com/gatsbyjs/gatsby-starter-hello-world(正如网站 https://www.gatsbyjs.com/starters/gatsbyjs/gatsby-starter-hello-world/ 所说)下载 hello world starter。当我 运行 gatsby develop 我看到以下错误

ERROR #11903  COMPILATION

There was an unhandled error during compilation for C:/Users/Owner/OneDrive/Desktop/reactRep/privateRep/gatsby-starter-hello-world. 
Please run the command with the --verbose flag again.


  Error: Error opening directory

not finished compile gatsby files - 0.514s

我尝试了很多东西,包括 npm audit fix --force,这实际上摧毁了一切,我不得不重新安装 node、react 和 gatsby-cli。是什么导致了这个错误?我还使用 npm 版本 8.5.0 和节点版本 16.14.2。 请在附件中找到我的终端机的完整副本:

PS C:\Users\Owner\OneDrive\Υπολογιστής\reactRep\privateRep-1\privateRep> npm install -g react

added 4 packages, and audited 5 packages in 743ms
found 0 vulnerabilities
PS C:\Users\Owner\OneDrive\Υπολογιστής\reactRep\privateRep-1\privateRep> npm install -g react-dom 

added 6 packages, and audited 7 packages in 695ms
found 0 vulnerabilities
PS C:\Users\Owner\OneDrive\Υπολογιστής\reactRep\privateRep-1\privateRep> npm install -g  react react-dom

removed 1 package, changed 9 packages, and audited 10 packages in 628ms

found 0 vulnerabilities
PS C:\Users\Owner\OneDrive\Υπολογιστής\reactRep\privateRep-1\privateRep> npm install -g bootstrap       
added 2 packages, and audited 3 packages in 2s

  run `npm fund` for details

found 0 vulnerabilities
PS C:\Users\Owner\OneDrive\Υπολογιστής\reactRep\privateRep-1\privateRep> gatsby -v
Gatsby CLI version: 4.10.1

PS C:\Users\Owner\OneDrive\Υπολογιστής\reactRep\privateRep-1\privateRep> npm install -g gatsby-cli      
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

added 378 packages, and audited 379 packages in 12s

61 packages are looking for funding
  run `npm fund` for details
3 moderate severity vulnerabilities

  npm audit fix --force

Run `npm audit` for details.
PS C:\Users\Owner\OneDrive\Υπολογιστής\reactRep\privateRep-1\privateRep> gatsby -v

PS C:\Users\Owner\OneDrive\Υπολογιστής\reactRep\privateRep-1\privateRep> npm gatsby new gatsby-starter-hello-world https://github.com/gatsbyjs/gatsby-starter-hello-world
Unknown command: "gatsby"

To see a list of supported npm commands, run:
  npm help
PS C:\Users\Owner\OneDrive\Υπολογιστής\reactRep\privateRep-1\privateRep> gatsby new gatsby-starter-hello-world https://github.com/gatsbyjs/gatsby-starter-hello-world    
info Creating new site from git: https://github.com/gatsbyjs/gatsby-starter-hello-world.git

Cloning into 'gatsby-starter-hello-world'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 15 (delta 0), reused 9 (delta 0), pack-reused 0
Receiving objects: 100% (15/15), 145.52 KiB | 2.17 MiB/s, done.
←[2K←[1A←[2K←[G←[32msuccess←[39m Created starter directory layout

←[2K←[1A←[2K←[G←[34minfo←[39m Installing packages...

npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated async-cache@1.1.0: No longer maintained. Use [lru-cache](http://npm.im/lru-cache) version 7.6 or higher, and provide an asynchronous `fetchMethod` option.
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated subscriptions-transport-ws@0.9.19: The `subscriptions-transport-ws` package is no longer maintained. We recommend you use `graphql-ws` instead. For help migrating Apollo software to `graphql-ws`, see https://www.apollographql.com/docs/apollo-server/data/subscriptions/#switching-from-subscriptions-transport-ws    For general help using `graphql-ws`, see https://github.com/enisdenjo/graphql-ws/blob/master/README.md

added 1478 packages, and audited 1479 packages in 41s

208 packages are looking for funding
  run `npm fund` for details

19 vulnerabilities (6 moderate, 13 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Your new Gatsby site has been successfully bootstrapped. Start developing it by running:

  cd gatsby-starter-hello-world
  gatsby develop


PS C:\Users\Owner\OneDrive\Υπολογιστής\reactRep\privateRep-1\privateRep\gatsby-starter-hello-world> gatsby develop --verbose
verbose set gatsby_log_level: "verbose"
verbose set gatsby_executing_command: "develop"
verbose loading local command from: C:\Users\Owner\OneDrive\Υπολογιστής\reactRep\privateRep-1\privateRep\gatsby-starter-hello-world\node_modules\gatsby\dist\commands\develop.js
verbose running command: develop

verbose Transition to "initializing"

 ERROR #11903  COMPILATION

There was an unhandled error during compilation for C:/Users/Owner/OneDrive/Υπολογιστής/reactRep/privateRep-1/privateRep/gatsby-starter-hello-world. Please run the command with the --verbose flag 
again.



  Error: Error opening directory

not finished compile gatsby files - 0.509s

PS C:\Users\Owner\OneDrive\Υπολογιστής\reactRep\privateRep-1\privateRep\gatsby-starter-hello-world> npm audit
# npm audit report

ansi-html  <0.0.8
Severity: high
Uncontrolled Resource Consumption in ansi-html - https://github.com/advisories/GHSA-whgm-jr23-g3j9
fix available via `npm audit fix --force`
Will install gatsby@2.32.13, which is a breaking change
node_modules/ansi-html
  @gatsbyjs/webpack-hot-middleware  *
  Depends on vulnerable versions of ansi-html
  node_modules/@gatsbyjs/webpack-hot-middleware
    gatsby  2.3.24-ink.60 - 2.3.24-ink.61 || >=2.6.0-alpha.1
    Depends on vulnerable versions of @gatsbyjs/webpack-hot-middleware
    Depends on vulnerable versions of @pmmmwh/react-refresh-webpack-plugin
    Depends on vulnerable versions of gatsby-cli
    Depends on vulnerable versions of react-dev-utils
    node_modules/gatsby
      babel-plugin-remove-graphql-queries  >=2.17.0-next.0
      Depends on vulnerable versions of gatsby
      node_modules/babel-plugin-remove-graphql-queries
      gatsby-plugin-page-creator  >=2.11.0-next.0
      Depends on vulnerable versions of gatsby
      Depends on vulnerable versions of gatsby-plugin-utils
      node_modules/gatsby-plugin-page-creator
      gatsby-plugin-typescript  >=2.13.0-next.0
      Depends on vulnerable versions of gatsby
      node_modules/gatsby-plugin-typescript
      gatsby-plugin-utils  >=0.10.0-next.0
      Depends on vulnerable versions of gatsby
      node_modules/gatsby-plugin-utils
  @pmmmwh/react-refresh-webpack-plugin  <=0.5.0-rc.6
  Depends on vulnerable versions of ansi-html
  node_modules/@pmmmwh/react-refresh-webpack-plugin

ansi-regex  >2.1.1 <5.0.1
Severity: moderate
 Inefficient Regular Expression Complexity in chalk/ansi-regex - https://github.com/advisories/GHSA-93q8-gq69-wqmw
fix available via `npm audit fix --force`
Will install gatsby@2.32.13, which is a breaking change
node_modules/yurnalist/node_modules/ansi-regex
  strip-ansi  4.0.0 - 5.2.0
  Depends on vulnerable versions of ansi-regex
  node_modules/yurnalist/node_modules/strip-ansi
    yurnalist  >=1.0.5
    Depends on vulnerable versions of strip-ansi
    node_modules/yurnalist
      gatsby-cli  2.5.9-ink.60 - 2.5.9-ink.61 || >=2.6.0-0
      Depends on vulnerable versions of yurnalist
      node_modules/gatsby/node_modules/gatsby-cli
        gatsby  2.3.24-ink.60 - 2.3.24-ink.61 || >=2.6.0-alpha.1
        Depends on vulnerable versions of @gatsbyjs/webpack-hot-middleware
        Depends on vulnerable versions of @pmmmwh/react-refresh-webpack-plugin
        Depends on vulnerable versions of gatsby-cli
        Depends on vulnerable versions of react-dev-utils
        node_modules/gatsby
          babel-plugin-remove-graphql-queries  >=2.17.0-next.0
          Depends on vulnerable versions of gatsby
          node_modules/babel-plugin-remove-graphql-queries
          gatsby-plugin-page-creator  >=2.11.0-next.0
          Depends on vulnerable versions of gatsby
          Depends on vulnerable versions of gatsby-plugin-utils
          node_modules/gatsby-plugin-page-creator
          gatsby-plugin-typescript  >=2.13.0-next.0
          Depends on vulnerable versions of gatsby
          node_modules/gatsby-plugin-typescript
          gatsby-plugin-utils  >=0.10.0-next.0
          Depends on vulnerable versions of gatsby
          node_modules/gatsby-plugin-utils

browserslist  4.0.0 - 4.16.4
Severity: moderate
Regular Expression Denial of Service in browserslist - https://github.com/advisories/GHSA-w8qv-6jwh-64r5
fix available via `npm audit fix --force`
Will install gatsby@2.32.13, which is a breaking change
node_modules/react-dev-utils/node_modules/browserslist
  react-dev-utils  6.0.0-next.03604a46 - 12.0.0-next.60
  Depends on vulnerable versions of browserslist
  Depends on vulnerable versions of immer
  node_modules/react-dev-utils
    gatsby  2.3.24-ink.60 - 2.3.24-ink.61 || >=2.6.0-alpha.1
    Depends on vulnerable versions of @gatsbyjs/webpack-hot-middleware
    Depends on vulnerable versions of @pmmmwh/react-refresh-webpack-plugin
    Depends on vulnerable versions of gatsby-cli
    Depends on vulnerable versions of react-dev-utils
    node_modules/gatsby
      babel-plugin-remove-graphql-queries  >=2.17.0-next.0
      Depends on vulnerable versions of gatsby
      node_modules/babel-plugin-remove-graphql-queries
      gatsby-plugin-page-creator  >=2.11.0-next.0
      Depends on vulnerable versions of gatsby
      Depends on vulnerable versions of gatsby-plugin-utils
      node_modules/gatsby-plugin-page-creator
      gatsby-plugin-typescript  >=2.13.0-next.0
      Depends on vulnerable versions of gatsby
      node_modules/gatsby-plugin-typescript
      gatsby-plugin-utils  >=0.10.0-next.0
      Depends on vulnerable versions of gatsby
      node_modules/gatsby-plugin-utils

immer  <9.0.6
Severity: high
Prototype Pollution in immer - https://github.com/advisories/GHSA-c36v-fmgq-m8hx
fix available via `npm audit fix --force`
Will install gatsby@2.32.13, which is a breaking change
node_modules/immer
  react-dev-utils  6.0.0-next.03604a46 - 12.0.0-next.60
  Depends on vulnerable versions of browserslist
  Depends on vulnerable versions of immer
  node_modules/react-dev-utils
    gatsby  2.3.24-ink.60 - 2.3.24-ink.61 || >=2.6.0-alpha.1
    Depends on vulnerable versions of @gatsbyjs/webpack-hot-middleware
    Depends on vulnerable versions of @pmmmwh/react-refresh-webpack-plugin
    Depends on vulnerable versions of gatsby-cli
    Depends on vulnerable versions of react-dev-utils
    node_modules/gatsby
      babel-plugin-remove-graphql-queries  >=2.17.0-next.0
      Depends on vulnerable versions of gatsby
      node_modules/babel-plugin-remove-graphql-queries
      gatsby-plugin-page-creator  >=2.11.0-next.0
      Depends on vulnerable versions of gatsby
      Depends on vulnerable versions of gatsby-plugin-utils
      node_modules/gatsby-plugin-page-creator
      gatsby-plugin-typescript  >=2.13.0-next.0
      Depends on vulnerable versions of gatsby
      node_modules/gatsby-plugin-typescript
      gatsby-plugin-utils  >=0.10.0-next.0
      Depends on vulnerable versions of gatsby
      node_modules/gatsby-plugin-utils

node-fetch  <2.6.7
Severity: high
node-fetch is vulnerable to Exposure of Sensitive Information to an Unauthorized Actor - https://github.com/advisories/GHSA-r683-j2x4-v87g
fix available via `npm audit fix`
node_modules/cross-fetch/node_modules/node-fetch
  cross-fetch  <=3.1.4 || >=3.2.0-alpha.0
  Depends on vulnerable versions of node-fetch
  node_modules/cross-fetch
    @graphql-tools/url-loader  <=7.4.3-alpha-9f8b9c45.0
    Depends on vulnerable versions of cross-fetch
    Depends on vulnerable versions of ws
    node_modules/@graphql-tools/url-loader

ws  7.0.0 - 7.4.5
Severity: moderate
ReDoS in Sec-Websocket-Protocol header - https://github.com/advisories/GHSA-6fc8-4gx4-v693
fix available via `npm audit fix`
node_modules/ws
  Depends on vulnerable versions of cross-fetch
  Depends on vulnerable versions of ws
  node_modules/@graphql-tools/url-loader

19 vulnerabilities (6 moderate, 13 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force```

如评论区所述,通过将项目文件夹移出 OneDrive 目录,问题已解决。

因为它是一个同步的云文件夹,所以只要您 install/add/delete/update 任何东西,它就会在 OneDrive 云中更新,因此 file/folder 它正在后台使用并且可能无法访问。如果此时您尝试开发项目(gatsby developgatsby build)并且正在使用该文件,您将无法 运行 它。

我认为使用云文件夹不是一个好习惯,因为同步的数据量(主要是因为node_modules)是需要关心的事情(在[=13中也被忽略了) =] 出于某种原因)所以将它移动到 OneDrive 目录之外的任何其他文件夹应该足以 运行 你的项目,因为根据你的日志,其余的全局依赖项已成功安装。