【问题标题】:Can not run 'npm run build' / 'npm run deploy' command in my react app无法在我的反应应用程序中运行“npm run build”/“npm run deploy”命令
【发布时间】:2019-04-27 23:54:26
【问题描述】:

我尝试使用 npm run deploy 在 github-pages 上部署我的 react 项目,但出现以下错误:

events.js:167
     throw er; // Unhandled 'error' event
     ^

Error: spawn git ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
    at onErrorNT (internal/child_process.js:407:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:11)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:238:12)
    at onErrorNT (internal/child_process.js:407:16)
    [... lines matching original stack trace ...]
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! songs@0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the songs@0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我已经使用了npm cache clean,删除了节点模块和 package-lock.json 并再次运行了npm install。我是 React 和一般编程的新手,所以我无法真正弄清楚问题所在。另外,我应该提到我是 Windows 用户。任何帮助将不胜感激。

【问题讨论】:

  • 你添加了 gh-pages 包吗?
  • 是的,我添加了 gh-pages 作为 devDependency。
  • 请检查这里有没有遗漏github.com/gitname/react-gh-pages
  • 我已经完成了所有的步骤......
  • 这是有道理的,因此,如果您将 git 二进制文件的位置添加到 Windows 中的 PATH 环境变量中,您可能会解决此问题。

标签: reactjs npm deployment


【解决方案1】:

解决方案是设置环境变量 $PATH。我按照这里提到的步骤:How do I debug “Error: spawn ENOENT” on node.js?

【讨论】:

    猜你喜欢
    • 2019-11-15
    • 1970-01-01
    • 1970-01-01
    • 2020-06-22
    • 1970-01-01
    • 2017-10-05
    • 1970-01-01
    • 2020-09-06
    • 2021-03-11
    相关资源
    最近更新 更多