npm 开发第一个gatsby项目时发生错误11903

lmyy7pcs  于 2022-11-14  发布在  其他
关注(0)|答案(2)|浏览(250)

我正在尝试建立我的第一个Gatsby网站。在运行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启动程序。当我运行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,它字面上摧毁了一切,我不得不重新安装节点,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```
7jmck4yq

7jmck4yq1#

正如在评论部分中所评论的,通过将项目文件夹移出OneDrive目录,该问题已得到解决。
因为它是一个同步的云文件夹,所以只要你安装/添加/删除/更新任何内容,它就会在OneDrive云中更新,因此该文件/文件夹会在后台使用,可能无法访问。如果此时你尝试开发项目(gatsby developgatsby build),而该文件正在使用,你将无法运行它。
我不认为使用云文件夹是一个好的做法,因为同步的数据量(主要是因为node_modules)它是需要关注的东西(在.gitignore中也会被忽略,这是有原因的),因此将它移动到OneDrive目录之外的任何其他文件夹应该足以运行您的项目,因为根据您的日志,其余的全局依赖项已成功安装。

lf5gs5x2

lf5gs5x22#

我遇到了同样的错误。我通过重命名项目目录路径中的文件夹以仅使用ASCII字符来解决问题。我发现您在项目所在的OneDrive子目录中有一些非ASCII字符,因此这可以解释为什么将项目移出OneDrive对您有效。
Gatsby Github repo有几个问题,涉及到路径中的非ASCII字符,这些路径似乎由于不活动而被关闭,但没有解决:#35609#11903中的一个或多个。

相关问题