After npm run deploy i have errors like above
Repo on Github
I am trying to deploy my react-app on gh-pages on Github (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:UsersjanAppDataRoamingnpm-cache_logs2017-05-12T17_55_00_56
9Z-debug.log
asked May 12, 2017 at 18:06
2
please install gh-pages
and it ready to go
To install
npm install gh-pages
to deploy
add this to package.json
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
and then this
npm run deploy
answered Dec 31, 2020 at 13:15
gh pages stands for GitHub Pages. It is simply a way to deploy a website via a github repo. Basically, NPM is yelling because when it attempts to run the command deploy, there is not link or reference to the line
$npm run build&&gh-pages -d build
You need make sure that gh-pages -d build
is defined. A place to start would be running gh-pages --man
or gh-pages --help
Brad Parks
65.8k63 gold badges255 silver badges332 bronze badges
answered May 12, 2017 at 18:18
I facing the same problem I do the following command before
git push
not working. After
git push
I do the same command it works correctly.
npm install gh-pages
and deploy
npm run deploy
answered Sep 7, 2022 at 5:19
Hello! So, the way npm run deploy
works is that it looks in your current package.json
for a defined "deploy"
script, and then runs that. The error message you’re seeing is trying to tell you that you have not defined a "deploy"
script in your package.json
, hence npm run deply
has no idea what you want it to do.
To solve this issue, all you have to do is add a new script to your package.json
. It might look something like this, for example:
{ "name": "package-name", "version": "1.0.0", "description": "package description", "scripts": { "deploy": "node --version", "test": "echo "Error: no test specified" && exit 1" }, "dependencies": {}, "devDependencies": {} }
Note how this package.json
has a "deploy"
script that runs node --version
. You’ll definitely want to change the command to whatever is most appropriate for your project.
Let me know if you run into any further npm
issues
I am developing react app in my localhost and try to deploy the code into github page.
But while running the command npm run deploy
its shows below error.
PS D:Projectsportfolio-app> npm run deploy
> portfolio-app@0.1.0 predeploy D:Projectsportfolio-app
> npm run build
> portfolio-app@0.1.0 build D:Projectsportfolio-app
> react-scripts build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
41.69 KB buildstaticjs2.b0b79569.chunk.js
2.35 KB buildstaticjsmain.2ad86f1d.chunk.js
1.4 KB buildstaticjs3.dc241c04.chunk.js
1.17 KB buildstaticjsruntime-main.b7252dff.js
546 B buildstaticcssmain.ab7136cd.chunk.css
The project was built assuming it is hosted at /me/.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
Find out more about deployment here:
https://cra.link/deployment
> portfolio-app@0.1.0 deploy D:Projectsportfolio-app
> gh-pages -b master -d build
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn git ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn git',
path: 'git',
spawnargs: [ 'config', 'user.name' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! portfolio-app@0.1.0 deploy: `gh-pages -b master -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the portfolio-app@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:UsersAppDataRoamingnpm-cache_logs2021-01-04T14_20_16_803Z-debug.log
PS D:Projectsportfolio-app>
Loading
Когда делал тестовое пришла информация, что нужно закинуть сайт на хост github pages. Уже имелся репозиторий с почти готовым проектом. При загрузке установил библиотеку npm install gh-pages --save-dev
, добавил в package.json в корне файла
"homepage": "https://Roman214-go.github.io/Coincap"
и в scripts
"predeploy": "npm run build",
"deploy": "gh-pages -b main -d build",
Запустил через npm run deploy и в итоге пишет:
error: cannot spawn sh: No such file or directory
fatal: unable to fork
Долго мучался и искал решение проблемы, максимум что выходило — это запускался README.md на хосте.
Надеюсь понятно описал проблему и найду тут помощь.
-
Вопрос задан02 авг. 2022
-
601 просмотр
Пригласить эксперта
Из-за чего может возникать ошибка
Скорее всего возникает при git clone. Если npm run deploy выполняется локально, то может проблема связана с доступом. Надо проверить, что папка, в которой выполняется команда, является репой и подключена корректно к GitHub — есть скрытая папка .git и после выполнения git remote -v есть remote с пометкой origin.
Другой вариант использовать параметр -repo:
gh-pages -d build -r <repo_url>
Также remote origin можно сбросить на всякий случай выполнив эти команды в папке репы:
$ git remote remove origin
$ git remote add origin https://github.com/Roman214-go/Coincap.git
$ git push -u origin master
А если кратко, то если все делать по этой инструкция от create-react-app — все должно заработать.
Что сейчас надо поправить и проверить на GitHub согласно инструкции
- Надо выбрать одну из веток (master или main) для изменений. Или смержить их и избавиться от одной(лучше от main). При мерже надо быть внимательным — в main ветке в packages.json продублированы команды predeploy и deploy
- gh-pages надо устанавливать через npm install —save gh-pages, т.е. не как devDependencies. Можно перенести из devDependencies в dependencies в packages.json и выполнить npm install
- в скриптах изменить «deploy»: «gh-pages -d build», — убрать » -b main», таким образом будет результат выполнения скрипта будет в ветке gh-pages
- Выполнить npm run deploy и проверить, что ветка появилась на GitHub
- В настройках проекта установить GitHub Pages на ветку gh-pages и в качестве папка в которую build сложился
Допы:
Как найти настройки проекта GitHub Pages для настр…
-
Показать ещё
Загружается…
04 июн. 2023, в 01:35
1500 руб./за проект
04 июн. 2023, в 01:25
40000 руб./за проект
03 июн. 2023, в 23:42
1500 руб./за проект