error computing cache key on circle-cl when I setup - reactjs

situation
I started to React project and pushed the default project to the git remote and connected to circle-cl
and set up and added config but the problem occurs. I don't know how to deal with this situation.
Restoring cache
error computing cache key: template: cacheKey:1:30: executing "cacheKey" at <checksum "~/project/package-lock.json">: error calling checksum: open /home/circleci/project/package-lock.json: no such file or directory
installingNpm packages
npm ERR! cipm can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm#5 or later to generate it, then try again.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/circleci/.npm/_logs/2020-10-12T03_01_22_810Z-debug.log
Exited with code exit status 1
CircleCI received exit code 1

solution
1.npm run start
2.added package-lock.json automatically(in my case)
3.git push
4.deployed success on circleci

Related

Failed to get remote.origin.url task must either be run in a git repository with a configured origin remote or must be configuredwith the 'repo option

In my weather-app I am using npm run deploy command in terminal
But it gives this error:
Failed to get remote.origin.url (task must either be run in a git repository with a configured origin remote or must be configured with the "repo" option).
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! weather_app#0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the weather_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! /home/pankaj/.npm/_logs/2021-11-22T19_38_21_874Z-debug.log
Also I don't know which command should i write to get access to my git repository which is already pushed on my github account...
I had the same issue. I solved it by putting the following commands in the terminal: git init, get remote add origin (copy and paste the url from your github repository here, the parentheses are not needed), and then npm run deploy
I cloned the repo again, did npm run deploy and it worked for me!
I had the same issue. I believe it was because I forgot to run "git init" at the start of development. I just cloned my repository and it sorted itself out.
I had this issue too...:
Initially I had my project on external hard disk so I made a local copy of my project and tried the "npm run deploy" command again and it worked for me. (Just make sure your remote origin is correct).
I hope this helps.

npm install error ENOTEMPTY: directory not empty,

I encountered the following error when I tried to install some new packages using npm install. It happened when I did npm install a-new-package --save and then delete package-lock.json file afterwards to refresh everything.
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /Users/memphismeng/Documents/React Programming/Foot-in-The-Door/mobile/fitd/node_modules/#babel/plugin-proposal-decorators
npm ERR! dest /Users/memphismeng/Documents/React Programming/Foot-in-The-Door/mobile/fitd/node_modules/#babel/.plugin-proposal-decorators-ysLLPQFw
npm ERR! errno -66
npm ERR! ENOTEMPTY: directory not empty, rename '/Users/memphismeng/Documents/React Programming/Foot-in-The-Door/mobile/fitd/node_modules/#babel/plugin-proposal-decorators' -> '/Users/memphismeng/Documents/React Programming/Foot-in-The-Door/mobile/fitd/node_modules/#babel/.plugin-proposal-decorators-ysLLPQFw'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/memphismeng/.npm/_logs/2021-06-15T18_07_01_162Z-debug.log
What went wrong? I also tried npm audit fix --legacy-peer-deps but it didn't work.
May be deleting node_modules folder and package-lock.json file and then reinstalling npm would resolve your issue.
So, consider the following commands to apply the above operations:
npm remove node_modules
npm remove package-lock.json
npm install
Obviously, the deleting of package.json is working but this is not always the desired solution. Sometimes you want to run:
npm i --package-lock-only //to update package.lock.json
npm audit fix
and then:
npm i
And this should be the first try but, I don't know why it didn't work in my case, which is in react native scenario. It seems like the error "npm install error ENOTEMPTY" is happening when the npm try to write to a folder that is not empty and in this case to "node_modules/#babel/.plugin-proposal-decorators-ysLLPQFw". If you run:
rm -rf node_modules/#babel/.plugin-proposal-decorators-ysLLPQFw
And then:
npm i
It should work this time. It should be a cleanup process of react-native though, and when working with web starter kit like CRA it never happened to me before.
I had the same problem while having a slow and unreliable Internet connection. I created this script that can be run with bash that fixes all of the interrupted installs:
#!/bin/bash
set -e
while true; do
log="$HOME/.npm/_logs/`ls $HOME/.npm/_logs/ | tail -n 1`"
echo "log: $log"
for path in `cat "$log" | grep 'ENOTEMPTY' | grep -oE "[^']+node_modules[^']+"`; do
echo "removing $path"
rm -rf "$path"
done
if npm install; then
break
fi
done
Basically, I use the approach from https://stackoverflow.com/a/69668434/1320237 but I just had too much do deal with manually.
Note: While it looks to me like it has a O(n * n) run time, it might have a O(n) download time for n = number of packages. So it is useful for slow Internet. You might be faster to just delete the node_modules directory if your Internet connection is fast.
I had a quite similar issue while working with npm.
What worked like a charm for me was updating my packages & dependencies for the project, specifically react-scripts.
Check what are your outdated packages with:
npm outdated
Or, follow the code snippets of this guy in medium, that automates the task of check and update your packages one by one.

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).

Can I develop the same reactjs app on two computers via dropbox

Im using two computers and want to sometimes develop on one computer and sometimes on another. But is it possible to develop the same react js app via two computers synching everything via dropbox so all the files stays in sync. Im getting this error when Im running npm start
sh: /Users/mycomputer/Dropbox/webb/myapp/node_modules/.bin/react-scripts: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! perottosson#0.1.0 start: `react-scripts start`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the perottosson#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
For using code in multiple computer, definitely you can use version control tool like Github/Bitbucket.
But the error you are facing is different. As you are coping the node modules also from 1 computer to another it is creating issue as it might happen that both PC has different node & npm version.
So never commit node_modules folder. It is auto create folder which will download all the dependencies when you hit npm install. So I suggest you to delete node_modules and then hit npm install and then start the project through npm start
You should look into using a source control software such as Git. You can create a free account at https://github.com and store your project on there. This allows you to modify it from any computer that has access
Please use something like git for this purpose.
You also could make a git file sync over your dropbox.

Resources