简体   繁体   中英

Receive error when deploy to GitHub pages

I'm deploy react app to git hub pages and receive error. File sizes after gzip:

68.67 KB  build\static\js\2.c2c334ae.chunk.js
 2.98 KB  build\static\js\main.8a72b1a2.chunk.js
  774 B   build\static\js\runtime~main.8f8a00a4.js

The project was built assuming it is hosted at /sort-customers-list/ . You can control this with the homepage field in your package.json .

The build folder is ready to be deployed. To publish it at https://sejob.github.io/sort-customers-list , run: npm run deploy

Find out more about deployment here:

sort-customers-list@0.1.0 deploy 
C:\Users\SeJo\Documents\Code\DEV_HW\sort-customers-list
gh-pages -d build

The "file" argument must be of type string. Received type undefined

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sort-customers-list@0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sort-customers-list@0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!    
C:\Users\SeJo\AppData\Roaming\npm-cache\_logs\2019-08-01T12_09_52_445Z-debug.log

The problem occurs in the new version of GitHub pages. Just use this command to install the previous version of GitHub pages:

npm install gh-pages@2.0.1

Hope it will help!

I also had this same problem on a fresh install of create-react-app . I have no idea what the problem was, but I did the following:

  1. Downgrade gh-pages from 2.1.0 to 2.0.1
  2. Instead of running npm run deploy , manually run npm run build then gh-pages -d build from the commandline.

At first, I'd get the same error in the commandline, even after checking that the version was downgraded to 2.0.1 , but for some reason it worked after manually creating the gh-pages branch and pushing some files into it. As of now, npm run deploy throws the error but at least gh-pages -d build from the console works.

INSTALL/REINSTALL GIT Update NPM Reopen EDITOR

this solved my problem

使用版本 2.0.1

npm i gh-pages@2.0.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM