【问题标题】:After npm run deploy errors occurednpm run deploy 后发生错误
【发布时间】:2017-05-12 18:06:40
【问题描述】:

在 npm run deploy 之后出现类似上述的错误
Repo on Github

我正在尝试在 Github 上的 gh-pages 上部署我的 react-app (create-react-app)

'gh-pages' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-world-4@0.1.0 deploy: `npm run build&&gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-world-4@0.1.0 deploy script 'npm run build&&gh-page
s -d build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the hello-world-4 package
,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run build&&gh-pages -d build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs hello-world-4
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls hello-world-4
npm ERR! There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jan\AppData\Roaming\npm-cache\_logs\2017-05-12T17_55_00_56
9Z-debug.log

【问题讨论】:

标签: node.js reactjs deployment npm github-pages


【解决方案1】:

所以我运行这个命令npm install --save gh-pages

如下图

之后我运行命令npm run deploy

我的代码发布成功,如下所示。

如需了解更多详情,请点击下方 Facebook 的此链接。

(https://facebook.github.io/create-react-app/docs/deployment#github-pages-https-pagesgithubcom)

希望您的问题能够得到解决。如有错误请回复。

【讨论】:

    【解决方案2】:

    请安装gh-pages,然后就可以使用了

    安装

    npm install gh-pages
    

    部署

    将此添加到package.json

    "predeploy": "npm run build",
     
    "deploy": "gh-pages -d build"
    

    然后是这个

    npm run deploy
    

    【讨论】:

      【解决方案3】:

      gh pages 代表 GitHub Pages。这只是一种通过 github repo 部署网站的方法。基本上,NPM 在大喊大叫,因为当它尝试运行命令 deploy 时,没有链接或引用该行

      $npm run build&&gh-pages -d build
      

      您需要确保已定义 gh-pages -d build。一个开始的地方是运行gh-pages --mangh-pages --help

      【讨论】:

        猜你喜欢
        • 2020-06-15
        • 2021-03-02
        • 1970-01-01
        • 1970-01-01
        • 2021-04-26
        • 1970-01-01
        • 1970-01-01
        • 2021-08-08
        • 2019-11-15
        相关资源
        最近更新 更多