Why can't I deploy my project onto Github? - reactjs

I've tried to deploy my app to github but it kept showing me this in the terminal :
Cloning into 'node_modules\gh-pages.cache\gwenmengue.github.io!robofriends'...
fatal: repository 'https://gwenmengue.github.io/robofriends/' not found
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! robofriends#0.1.0 deploy: gh-pages -d build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the robofriends#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\username\AppData\Roaming\npm-cache_logs\2019-11-04T18_18_25_037Z-debug.log
I joined a screenshot of my package.json file by the way!: https://i.stack.imgur.com/FLTmm.jpg
Moreover when I was running the operations, I was in my project directory so I don't understand what wasn't working ?
Kindly guide me how to solve this issue. Thanks.

First, make sure you CAN push your project to github from your project folder. Your credentials, remote repo, etc need to be setup and working before the script will work.
Just in case you need help with this, see this github help page
If you are able to push your project successfully to Github from the same project folder your terminal command is in, then try building and running your commands again:
npm run build
npm run deploy
This gh-pages article on Medium might be helpful as well. Also, if you want to change any of your gh-pages variables (so you can deploy your static code to a different repository in case that's what you're trying to do), here's the project page for gh-pages.
I, for example, am deploying ONLY my static build directory to a completely different public repository in Github, while keeping my React project source files in a different private repository. Github doesn't allow you to host pages from private repositories unless you pay, so I just use two repositories :). In order to achieve this, in script area of my package.json, I added the following options to the gh-pages command in my deploy directive:
"deploy": "gh-pages -d build -r https://github.com/MyGitHubName/web.git -o web",
The -r option lets you enter a different repository url, and the -o option allows you to enter a different remote origin for deploying your code, in my case I named it "web" because that's the same name as my public repository on Github.
You can list all of your existing remotes with:
git remote -v
You would setup a different remote in your local git environment with:
git remote add YourNewRemoteName https://github.com/YOURGITHUBNAME/YOURPROJECTNAME
I apologize in advanced if this is all info you already know, but when I was having trouble deploying my project, I found all of this info useful. Cheers.

Related

Why does my sanity.io project keep failing at the last step?

I am trying to start a new sanity project, it keeps on failing, this is my first time using it, I have tried it on the command prompt and in my vscode terminal, always fail at exactly here:
PS C:\Users\USER\Documents\portfolio> cd .\backend_sanity
PS C:\Users\USER\Documents\portfolio\backend_sanity> npm create sanity#latest -- --coupon javascriptmastery2022
Coupon "javascriptmastery2022" validated!
You're setting up a new project!
We'll make sure you have an account with Sanity.io. Then we'll
install an open-source JS content editor that connects to
the real-time hosted API on Sanity.io. Hang on.
Press ctrl + C at any time to quit.
Prefer web interfaces to terminals?
You can also set up best practice Sanity projects with
your favorite frontends on https://www.sanity.io/templates
Looks like you already have a Sanity-account. Sweet!
✔ Fetching existing projects
? Project name: website
Your content will be stored in a dataset that can be public or private, depending on
whether you want to query your content with or without authentication.
The default dataset configuration has a public dataset named "production".
? Use the default dataset configuration? Yes
✔ Creating dataset
? Project output path: C:\Users\USER\Documents\portfolio\backend_sanity
? Select project template Clean project with no predefined schemas
? Do you want to use TypeScript? Yes
✔ Bootstrapping files from template
✔ Resolving latest module versions
✔ Creating default project files
? Package manager to use for installing dependencies? npm
Running 'npm install --legacy-peer-deps'
npm WARN deprecated sourcemap-codec#1.4.8: Please use #jridgewell/sourcemap-codec instead
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! network Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USER\AppData\Local\npm-cache\_logs\2023-01-01T14_05_15_828Z-debug-0.log
Error: Command failed with exit code 1 (Unknown system error -1): npm install --legacy-peer-deps
at makeError$1 (C:/Users/USER/AppData/Local/npm-cache/_npx/67a0730928194b24/node_modules/#sanity/cli/lib/_chunks/cli-0bbdf4ec.js:1614:1386)
at handlePromise (C:/Users/USER/AppData/Local/npm-cache/_npx/67a0730928194b24/node_modules/#sanity/cli/lib/_chunks/cli-0bbdf4ec.js:1694:959)
at async installDeclaredPackages (C:/Users/USER/AppData/Local/npm-cache/_npx/67a0730928194b24/node_modules/#sanity/cli/lib/_chunks/cli-0bbdf4ec.js:1694:4672)
at async initSanity (C:/Users/USER/AppData/Local/npm-cache/_npx/67a0730928194b24/node_modules/#sanity/cli/lib/_chunks/cli-0bbdf4ec.js:17019:4972)
PS C:\Users\USER\Documents\portfolio\backend_sanity>
I tried to start a sanity project, I ran the command to create and it fails at the last stage

issue deploying to vercel, works on local?

Trying to my Next.js app using vercel, have tried both the cli and web app. Either way, not working. Error log:
2022-04-18T00:57:21.354Z Retrieving list of deployment files...
2022-04-18T00:57:23.121Z Downloading 29 deployment files...
2022-04-18T00:57:24.298Z Installing build runtime...
2022-04-18T00:57:27.316Z Build runtime installed: 3.018s
2022-04-18T00:57:27.999Z Looking up build cache...
2022-04-18T00:57:28.609Z Build Cache not found
2022-04-18T00:57:28.805Z Installing dependencies...
2022-04-18T00:57:30.687Z npm ERR! code ENOLOCAL
2022-04-18T00:57:30.692Z npm ERR! Could not install from "node_modules/eth-sig-util/ethereumjs-abi#git+https:/github.com/ethereumjs/ethereumjs-abi.git" as it does not contain a package.json file.
2022-04-18T00:57:30.713Z
2022-04-18T00:57:30.713Z npm ERR! A complete log of this run can be found in:
2022-04-18T00:57:30.713Z npm ERR! /vercel/.npm/_logs/2022-04-18T00_57_30_693Z-debug.log
2022-04-18T00:57:30.725Z Error: Command "npm install" exited with 1
2022-04-18T00:57:31.523Z
Not sure what is causing this. I am able to npm run dev on local and everything works correctly. I am also able to npx next build and that works fine too. Any ideas how to fix this issue? Thanks

how to avoid other git local repository projects be recognized as unstaged changes?

Recently I was building a very basic react projector for learning reasons and I faced with a very annoying problem described by theses logs:
npm ERR! errno 1
npm ERR! react-tutorial-guide#0.1.0 eject: `react-scripts eject`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-tutorial-guide#0.1.0 eject 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\admin\AppData\Roaming\npm-cache\_logs\2021-01-09T22_43_29_500Z-debug.log
I did a quick search, spent a lot of hours I finally I found the problem.
There was some unstaged change in my projects so I should do:
git add .
git commit -am "some message"
to solve the problem, I did it and in the principle, the problem wasn't been solved. I saw more carefully my project and I could see that git local repositories outside my react projects folder was been considered as unstaged changes. So when I try to commit my project by the commands above, it failed and consequentially the problem wasn't been solved what doesn't make sense they were outside my project folder and I was inside my project folder when I executed the git commands to solve the problem.
I investigated more carefully to solve the problem, so I noted that My reacts project is inside a folder, where there is other react projects, and this React projects folder was inside the document user folder, to be more precise in this path on my os system (windows 10): C:\Users(USER_NAME)\Documents
To solve the problem I simply deleted the folder where there were local git repositories and finally I could execute the wanted task:
npm run eject
I know this solution is very bad, but it was the only one that I was able to do and it is too annoying because it will cause me future problem in the react projects where I have to execute
npm run eject
in my projects when it were needed. I'm finding a better solution and if someone could show me how to avoid this issue I would be too thankfully.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\admin\AppData\Roaming\npm-cache\_logs\2021-01-09T22_43_29_500Z-debug.log
In my opinion, it is not a problem with git. The error which you got is probably because of the way that you have installed the node or npm in your system. Maybe by updating the npm would have also solved your problem.
npm install -g npm
You can also download the latest version of node.js from the official site.
There is an another way of updating the node through node version manager(nvm). Please follow the instruction for installing or updating the nvm.

Could not read from a remote repository when publishing my site

I am using docusaurus to write a documentation website for a product. I made some customizations to the site and try to publish it on GitHub.
Following the tutorial, I config the website/siteConfig.js, ran npm run build and used :
$ GIT_USER=<GIT_USER> CURRENT_BRANCH=master USE_SSH=true npm run publish-gh-pages
to push it to Github. Cloning to gh-pages fails and shows "fatal: Could not read from remote repository." error.
The following git commands were what I used.
LM-SHC-16507799:website benshi$ ls
README.md core node_modules sidebars.json yarn.lock
blog git package.json siteConfig.js
build i18n pages static
LM-SHC-16507799:website benshi$ pwd
/Users/user_name/Desktop/calender/week_3/docusaurus-exp/website
LM-SHC-16507799:website user_name$ GIT_USER=my_github_user_name CURRENT_BRANCH=master USE_SSH=true npm run publish-gh-pages
It failed. The following error messages were shown.
> # publish-gh-pages /Users/user_name/Desktop/calender/week_3/docusaurus-exp/website
> docusaurus-publish
master
https://github.com/my_github_user_name/docusaurus-exp.git
generate.js triggered...
feed.js triggered...
feed.js triggered...
sitemap.js triggered...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
Site built successfully. Generated files in 'build' folder.
89b1f1bd2f7e2403a08a194a89379916edcbb540
Cloning into 'docusaurus-exp-gh-pages'...
ssh_exchange_identification: read: Operation timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Error: git clone failed
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # publish-gh-pages: `docusaurus-publish`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # publish-gh-pages 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! /Users/user_name/.npm/_logs/2019-07-18T07_15_37_998Z-debug.log
The issue is not related with Docusaurus indeed.
The error was cause when I tried to publish the site tp gh-pages branch with USE_SSH=true. In fact I don't have SSH stored on this machine. The issue was resolved by romoving this parameter (or set USE_SSH=false).

Install dependencies with npm from private gitlab repo

I'm trying to install a package that exists on our private repo. The goal is to share the repo with a partner, but I need to make sure they can install it. In theory, it should work, but none of the documented solutions are working for me
I've tried adding the package to the package.json file
"dependencies": {
"package_name": "git+https://<deploy-token-name>:<deploy-token>#gitlab.domain.com/group/repo.git"
}
And then installing with npm but it seems to fail on the deploy token, but it's hard to say because the log isn't very helpful and then our whole gitlab deployment goes down for a moment #fun
29 error
29 error undefined
29 error exited with error code: 128
I've also tried with a private access token
"package-name": "https://oauth2:<access-token>#gitlab.domain.com/group/repo.git"
This results in an actual error that I can understand, except the error is saying there isn't a package.json in the repository, but there most certainly is
npm ERR! package.json Non-registry package missing package.json: package-name#https://oauth2:<access-token>#gitlab.domain.com/group/repo.git.
npm ERR! package.json npm can't find a package.json file in your current directory.
I've tried with ssh (with a ssh key setup that works for commits etc)
git+ssh://git#my-domain.com:my-project/my-repo#my-branch
And that results in an error
npm ERR! premature close
I've read through a dozen related issues and articles, but nothing is working for me
Install npm module from gitlab private repository
Install npm module from gitlab private repository
Use dependencies from a private GitLab with NPM
https://hackernoon.com/private-npm-packages-2e6579b37616
I've got the same issue and I managed to fix it.
The gitlab repository that I wanted to install didn't have a package.json file.
Check dependency package.json
On npm install, the error npm ERR! premature close seems common if there's any problems with depency package.json's...
Does a package.json exist?
Is everything inside absolutely correct?
Everything ok with dependencies dependencies?
In my case, I had an illegal version number ("1" instead of "1.0.0"). This was not an issue on my local environment, but only when deploying to remote production. Fixing this cleared the error right away.
For reference this is my dependency line:
"myCustomRepo" : "git+https://MyGithubUsername:MyGithubPublicAccessToken#github.com/MyGithubUsername/myCustomRepo"
You should use Scopes if you want to install private npm packages.
You can define a scope in .npmrc file of your repository.
example .npmrc in your application repo:
#scopeName:registry=http://private-npm-registry/
always-auth=true
So npm can handle a dependency like:
#scopeName/yourprivateModule#version
The token to access this repo should not be included in your Repository in should be configured in your home folders .npmrc .
Npm will first look in ther current folder for a .npmrc and later in your home folder. The configured options will be merged.
But this approach is only good for you if you publish your package to a private npm registry.
https://docs.gitlab.com/ee/user/project/packages/npm_registry.html#authenticating-with-an-oauth-token
So to summarize this:
configure your scope in a .npmrc file of your repository
configure access token in .npmrc file of your environment user
add scoped dependency to your package.json
e.g.
npm i #scopeName/yourprivateModule#version

Resources