发生 npm run deploy 错误后

Luk*_*kas 3 deployment node.js npm github-pages reactjs

在 npm run deploy 之后,我在 Github 上遇到了类似上面Repo 的错误

我正在尝试在 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
Run Code Online (Sandbox Code Playgroud)

Abh*_*mar 10

我得到了这样的错误

So I run this command npm install --save gh-pages

like below

像这样运行命令

After that I run the command npm run deploy

My code published successfully like below.

我的代码发布成功

For more details just follow this link by Facebook which is given below.

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

I hope your issue will be resolved. In case of error please reply.


小智 5

请安装gh-pages并准备就绪

安装

npm install gh-pages
Run Code Online (Sandbox Code Playgroud)

部署

将其添加到package.json

"predeploy": "npm run build",
 
"deploy": "gh-pages -d build"
Run Code Online (Sandbox Code Playgroud)

然后这个

npm run deploy
Run Code Online (Sandbox Code Playgroud)