【问题标题】:Gatsby develop not working after creating a project创建项目后盖茨比开发无法正常工作
【发布时间】:2021-01-21 11:24:20
【问题描述】:

我创建了一个 Gatsby 项目,每当我运行 gatsby developnpm run develop 时,我都会收到以下错误:


UNHANDLED REJECTION spawn node ENOENT

  Error: spawn node ENOENT

  - child_process:277 Process.ChildProcess._handle.onexit
    node:internal/child_process:277:19

  - child_process:477 onErrorNT
    node:internal/child_process:477:16

  - task_queues:81 processTicksAndRejections
    node:internal/process/task_queues:81:21


npm ERR! code 1
npm ERR! path D:\Code\Gatsby test project\gatsby-test
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c gatsby develop

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\marti\AppData\Local\npm-cache\_logs\2021-01-21T10_50_22_321Z-debug.log```

gatsby buildgatsby clean 等其他脚本在我运行它们时可以工作,但 npm run developnpm start 并非如此

首先,我尝试卸载 node_modules 并删除 package-lock.json 并运行 npm install 但我仍然收到错误消息。 我尝试卸载gatsby-cli 并使用npm init gatsby 创建一个项目,但再次没有区别。最后,我完全卸载了 Nodejs 并安装了最新版本,但每次尝试启动开发服务器时仍然得到Error: spawn node ENOENT

我有使用 React 的经验,但我是 Gatsby 的新手。我最近遇到了我的节点问题,运行npm start 什么也没做,而是让我回到控制台。问题是我的 Nodejs 文件夹安装在 D:\ 而不是 C:\ 驱动器中,而且 react-scripts 版本旧但简单的重新安装解决了问题。

我没有更改项目中的任何内容,但这里是 package.json 文件:

  "name": "gatsby-starter-hello-world",
  "private": true,
  "description": "A simplified bare-bones starter for Gatsby",
  "version": "0.1.0",
  "license": "0BSD",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
    "start": "npm run develop",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
  },
  "dependencies": {
    "gatsby": "^2.26.1",
    "react": "^16.12.0",
    "react-dom": "^16.12.0"
  },
  "devDependencies": {
    "prettier": "2.2.1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/gatsbyjs/gatsby-starter-hello-world"
  },
  "bugs": {
    "url": "https://github.com/gatsbyjs/gatsby/issues"
  }
}

如果有人指出问题所在,我将不胜感激。 感谢您的宝贵时间!

【问题讨论】:

  • 这是一个节点相关的问题。你能再调试一下吗?在项目的根目录上运行node -v 会发生什么?也许它不在正确的路径中
  • 当我在根目录下运行node -v 时,它会显示最新版本(v15.6.0)。它应该是正确的路径,因为我在创建项目并运行 npm run develop 后将 cd 放入文件夹并运行 npm run develop 但它不起作用。
  • 您可以尝试下载一个全新的启动器并再试一次吗?
  • 我得到了同样的Error: spawn node ENOENT
  • 如果是节点相关的问题,并且我已经重装了几次,是否可以尝试重装操作系统?

标签: node.js reactjs npm gatsby cypress


【解决方案1】:

对于那些可能遇到同样麻烦的人:问题终于解决了:

npm run develop:cypress

【讨论】:

    猜你喜欢
    • 2020-09-15
    • 1970-01-01
    • 2021-10-03
    • 2021-04-09
    • 2016-03-09
    • 2021-01-21
    • 2022-07-01
    • 2022-08-04
    • 1970-01-01
    相关资源
    最近更新 更多