简体   繁体   中英

Why I get an error when I try to deploy a react app to GitHub Pages?

I tried to deploy a react app to GitHub pages...

Commands on package.json:

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

and received this error:

The "file" argument must be of type string. Received type undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the my-app@0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

It was supposed to deploy.

I've resolved mine.Newer version 2.1 has some issue. Revert back to 2.0.1.

  • Reinstall Github pages with a specific version:
npm uninstall gh-pages

npm i gh-pages@2.0.1

npm run deploy // as usual

Hope that helped. :)

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