There appears to be trouble with the npm registry (returned undefined). Retrying - reactjs

I'm trying to install dependencies in my project but when I run yarn install I get the following error
[2/5] 🔍 Resolving packages...
info There appears to be trouble with the npm registry (returned undefined). Retrying...
info There appears to be trouble with the npm registry (returned undefined). Retrying...
info There appears to be trouble with the npm registry (returned undefined). Retrying...
info There appears to be trouble with the npm registry (returned undefined). Retrying...
⠁ axios#0.21.1/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:66965
throw new (_errors || _load_errors()).ResponseError(_this3.reporter.lang('requestFailed', description), res.statusCode);
^
ResponseError: Request failed "502 Bad Gateway"
at ResponseError.ExtendableBuiltin (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:696:66)
at new ResponseError (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:802:124)
at Request.params.callback [as _callback] (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:66965:19)
at Request.self.callback (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:140749:22)
at Request.emit (events.js:315:20)
at Request.<anonymous> (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:141721:10)
at Request.emit (events.js:315:20)
at IncomingMessage.<anonymous> (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:141643:12)
at Object.onceWrapper (events.js:421:28)
at IncomingMessage.emit (events.js:327:22) {
responseCode: 502
}
I tried
to remove yarn.lock file and run yarn install again
to increase network timeout yarn install --network-timeout 100000
Still getting the same error

this worked for me:
Delete any "*.lock" and rm node_modules. Or rm -rf node_modules/
Clean a flush all connections things like DNS, caches and so on.
Terminal commands:
set http_proxy=
set https_proxy=
yarn config delete proxy
npm config rm https-proxy
npm config rm proxy
npm config set registry "http://registry.npmjs.org" or npm config set registry "https://registry.npmjs.org"
Restart your terminal and Try.
Use : yarn add mypckge --network-timeout 100000 or yarn --network-timeout 100000
but first try just yarn
Restart your terminal and Try yarn again and/or with --network-timeout.
link to MichelDiz answer

Related

can't able to install react using npx create-react-app

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! network Invalid response body while trying to fetch https://registry.npmjs.org/eslint-plugin-jsx-a11y: 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! /home/purushot/.npm/_logs/2021-12-07T08_23_28_234Z-debug-0.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
npm version is 8.0.2
node version is 16.13.1
ubuntu version is 20.04.3
can look at full log here https://codepen.io/purushot-frontend/pen/OJxNPgQ
update: Can't able to find exact reason but rolled back to node version 12.22.7, npm v6.14.15 and its working again.
This seems to be a slow internet connection issue. Try increasing the timeout from 30s to 60s by adding this to your .npmrc file:
"timeout=60000"
You could also try adding "prefer-offline=true" if you are trying to save bandwidth or have a slow connection
Note: if you don't have an .npmrc file setup yet, you can create one here
for Windows: C:\Users{username}.npmrc
for Mac/Linux ~/.npmrc
Or you can create one in the same directory as your project's package.json file.
I was facing the same issue when creating a react-app using npx create-react-app . And I fixed my problem by running the following command.
npm cache clean --force
And then
npx create-react-app [app-name]

What am i doing wrong?, Am creating react app with, npx create-react-app app_name. but i keep getting thing unusual error

C:\Users\user>npx create-react-app my-app-redux-demo
Creating a new React app in C:\Users\user\my-app-redux-demo.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
core-js#2.6.12 postinstall C:\Users\user\my-app-redux-demo\node_modules\babel-runtime\node_modules\core-js
node -e "try{require('./postinstall')}catch(e){}"
core-js#3.9.0 postinstall C:\Users\user\my-app-redux-demo\node_modules\core-js
node -e "try{require('./postinstall')}catch(e){}"
core-js-pure#3.9.0 postinstall C:\Users\user\my-app-redux-demo\node_modules\core-js-pure
node -e "try{require('./postinstall')}catch(e){}"
ejs#2.7.4 postinstall C:\Users\user\my-app-redux-demo\node_modules\ejs
node ./postinstall.js
cra-template#1.1.2
react-scripts#4.0.2
react-dom#17.0.1
react#17.0.1
added 1903 packages from 722 contributors and audited 1906 packages in 463.186s
127 packages are looking for funding
run npm fund for details
found 0 vulnerabilities
Git repo not initialized Error: Command failed: git --version
at checkExecSyncError (child_process.js:611:11)
at execSync (child_process.js:647:15)
at tryGitInit (C:\Users\user\my-app-redux-demo\node_modules\react-scripts\scripts\init.js:46:5)
at module.exports (C:\Users\user\my-app-redux-demo\node_modules\react-scripts\scripts\init.js:283:7)
at [eval]:3:14
at Script.runInThisContext (vm.js:131:20)
at Object.runInThisContext (vm.js:297:38)
at Object. ([eval]-wrapper:10:26)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at evalScript (internal/process/execution.js:94:25) {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 6444,
stdout: null,
stderr: null
}
Installing template dependencies using npm...
npm WARN registry Unexpected warning for http://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-zJmm08OqHoWE/tbPBA3EoM3NqC+jSXNrjmFOL793hAbIsvaQb1AGlZwyklCdorV7Smk99/CUEbGMX4WyYp9eOQ== integrity checksum failed when using sha512: wanted sha512-zJmm08OqHoWE/tbPBA3EoM3NqC+jSXNrjmFOL793hAbIsvaQb1AGlZwyklCdorV7Smk99/CUEbGMX4WyYp9eOQ== but got sha512-bT3IYAdf9Eqxmgn6hiWRbSzk6tLXQqI9oMekX8vYrhnaMN7MK7A7uYzVR2dlbf0vqr5HvYW2DOV61NEoGJXTVQ==.
(180727 bytes)
npm WARN registry Using stale data from http://registry.npmjs.org/ due to a request error during revalidation.
npm ERR! code EINTEGRITY
npm ERR! errno EINTEGRITY
npm ERR! Invalid response body while trying to fetch http://registry.npmjs.org/#testing-library%2fuser-event: Integrity verification failed for sha512-zJmm08OqHoWE/tbPBA3EoM3NqC+jSXNrjmFOL793hAbIsvaQb1AGlZwyklCdorV7Smk99/CUEbGMX4WyYp9eOQ== (C:\Users\user\AppData\Roaming\npm-cache_cacache\content-v2\sha512\cc\99\a6d3c3aa1e8584fed6cf040dc4a0cdcda82fa349736b8e614e2fbf778406c8b2f6906f5006959c3292509da2b57b4a693df7f09411b18c5f85b2629f5e39)
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Roaming\npm-cache_logs\2021-02-19T14_10_23_648Z-debug.log
npm install --save #testing-library/jest-dom#^5.11.4 #testing-library/react#^11.1.0 #testing-library/user-event#^12.1.10 web-vitals#^1.0.1 failed
Looks like the directory where you ran CRA doesn't allow initializing a git repo. Could it be read-only?. Try git init in a new directory in the same path and if it fails - troubleshoot that. Once it succeeds, CRA should work too.
Check to ensure that you have correctly installed git by following the installation process outlined on https://git-scm.com/book/en/v2/Getting-Started-Installing-Git.
After installing, you can confirm that git is installed by running git --version (what React is trying to do). Currently, you will likely see an error trying to run this command as git is not installed. Post-install, you should see a version number being displayed.
After installing git, run your create-react-app again.

An error occurred while running subprocess npm. ionic start

I try to start a new ionic project. I did those steps
1.npm install -g #ionic/cli
2.ionic start
and I got those errors related to npm. I searched but could not find a solution.
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-F4TxbIf2Zho1u0gkwk7pMZkuAOcjie2Ifj9Txahek0JAUamP58o+0YUlXp2xApo68CRZSFS4nMA5h897G2Q93A== integrity checksum failed when using sha512: wanted sha512-F4TxbIf2Zho1u0gkwk7pMZkuAOcjie2Ifj9Txahek0JAUamP58o+0YUlXp2xApo68CRZSFS4nMA5h897G2Q93A== but got sha512-T7rpJR5srgZoHOMh8Kv1DDE6mbnW43SNUk9aRhPXGCfF2iJZoTEItjVYHC/gvtncRQCksb8Tk6f72HLaB6la0A==. (50573 bytes)
npm WARN registry Using stale data from https://registry.npmjs.org/ due to a request error during revalidation.
npm WARN deprecated core-js#2.6.11: core-js#<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js#3.
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! https://npm.community
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Admin\AppData\Roaming\npm-cache_logs\2020-05-05T06_02_58_568Z-debug.log
[ERROR] An error occurred while running subprocess npm.
Delete package-lock.json file from your project, if it is created.
Check your npm version using
npm -v
If your npm version is 5 and above. Then run the following command:
npm cache verify
Then run your install command
npm install -g #ionic/cli
In case you are having the same issue.
I found a solution for this. Go to your terminal and run
npm cache clean --force or remove npm-cache folder manually from C:\Users\Admin\AppData\Roaming
And then run ionic start again

I am trying to create react app .but I got error

`C:\Windows\System32>npx create-react-app my-app
Creating a new React app in C:\Windows\System32\my-app.
Installing packages. This might take a couple of minutes. Installing
react, react-dom, and react-scripts with cra-template...
yarn add v1.22.0 [1/4] Resolving packages... [2/4] Fetching
packages... error An unexpected error occurred:
"C:\Users\ADMIN\AppData\Local\Yarn\Cac
he\v6\npm-levenary-1.1.1-842a9ee98d2075aa7faeedbe32679e9205f46f77-integrity\n
ode_modules\levenary\.yarn-metadata.json: Unexpected end of JSON
input". info If you think this is a bug, please open a bug report with
the information p rovided in
"C:\Windows\System32\my-app\yarn-error.log". info Visit
https://yarnpkg.com/en/docs/cli/add for documentation about this comm
and. info There appears to be trouble with your network connection.
Retrying... info There appears to be trouble with your network
connection. Retrying... info There appears to be trouble with your
network connection. Retrying... info There appears to be trouble with
your network connection. Retrying... info There appears to be trouble
with your network connection. Retrying... info There appears to be
trouble with your network connection. Retrying... info There appears
to be trouble with your network connection. Retrying... error
https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.11.tgz:
ESOCKETTIMEDO UT
Aborting installation. yarnpkg add --exact react react-dom
react-scripts cra-template --cwd C:\Window s\System32\my-app has
failed.
Deleting generated file... package.json Deleting generated file...
yarn.lock Done.
C:\Windows\System32>cd my-app
C:\Windows\System32\my-app>npm start npm ERR! code ENOENT npm ERR!
syscall open npm ERR! path C:\Windows\System32\package.json npm ERR!
errno -4058 npm ERR! enoent ENOENT: no such file or directory, open
'C:\Windows\System32\pac kage.json' npm ERR! enoent This is related to
npm not being able to find a file. npm ERR! enoent
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\ADMIN\AppData\Roaming\npm-cache_logs\2020-03-02T10_07_42_
156Z-debug.log`
Try with npx (npm 5.2+ and higher) : https://create-react-app.dev/docs/getting-started/
Hello
Dear,
first, install node js and then npm and then try to restart your pc
after restart PC
npm install -g create-react
for better result restart more 1 time
and then
npx create-react-app my-app
I hope finally you success to install your app
Or more please visit this Demo
first, install node js and then npm
and then try the command
create-react-app my-app

Error "rollbackFailedOptional" on create-react-app

I'm learning React. I got this 2 errors in the screenshots below (links) when running:
npm i -g create-react-app#1.5.2
Screenshots:
https://i.ibb.co/S7yszvz/Capture.png
https://i.ibb.co/4Y7LY6X/Capture2.png
The errors:
[..................] / rollbackFailedOptional: verb npm-session 8a15f24eef6f3714
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://registry.npmjs.org/create-react-app
failed, reason: connect ETIMEDOUT 10.21.30.247:80
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'
What I tried:
npm config rm proxy
npm config rm https-proxy
npm config set registry http://registry.npmjs.org/
npm config get https-proxy (returns null)
I'm hoping for some help so I can make progress. Thanks
I finally did it using my phone network (must have been the firewall), but then:
C:\UserXXXX\Desktop\js REACT>create-react-app react-app
Creating a new React app in C:\UserXXXX\\Desktop\js REACT\react-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to http://registry.npmjs.org/posix-character-
classes/-/posix-character-classes-0.1.1.tgz failed, reason: getaddrinfo ENOTFOUND
registry.npmjs.org registry.npmjs.org:80
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:\UserXXXX\AppData\Roaming\npm-cache\_logs\2018-12-
11T10_28_30_314Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting react-app / from C:\UserXXXX\Desktop\js REACT
Done.
I was facing similar issue a while back with npx create-react-app my-app as well.
So I reinstalled NodeJs and then tried removing proxy set up from npm config by following commands:
npm init
npm config rm proxy
npm config rm https-proxy
and then try the command npm i -g create-react-app#X.X.X again.

Resources