npm install axios not working in my react native app? - reactjs

I am new to developing react native app. I'm facing problem while installing axios using the command npm install axios in my terminal.
I have tried below code as well to install axios library:
npm install --save axios
npm i axiois --save
So what is the problem why I am not able to get dependencies in my app?
A small request also is install and i are the same in this npm command?
UPDATE
Here is the log that might help you:
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://registry.npmjs.org/axios failed, reason: connect ETIMEDOUT 104.16.21.35:443
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!
UPDATE 2
As everyone is pointing to a network problem I have tried all the answer and commentes you have provided but nothing works, but I am able to use internet on my PC easily means device in which I am running this command.
npm install axios
on the same device I am using browser, spotify and in terminal I just installed vlc using apt-get install so there is no chance of technical issue. Thank you all for help but nothing working is there any other solution?

It is clearly related to your system's network. Try changing your network by creating a hotspot from other devices.

Its network related issue make sure u have an active internet connection while installing axiois.

Try un-installing and then install it again
npm uninstall axios
npm i axios

check you network connection
after that do system update:
1) sudo apt-get update
try running the command again.

Here according to your log it may be your internet connection problem or proxy settings problem.
Try to reconnect to the internet and make sure you have active internet connection.
If reconnecting to different internet connection still does not solve your issue try to run this command :
npm cache verify
Check your config settings: npm config list
Then you could add or change your proxy settings:
npm config set http-proxy http://your_proxy_ip:port
npm config set https-proxy http://your_proxy_ip:port
Refer
Refer

Connect to hotspot and try installing , worked for me

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

Create-react-app dependency version issues

I am trying to create a basic react app using the command:
npx create-react-app my-app
At work we use JFrog Artifactory to manage our npm packages. When trying to use the above command, I get the following error:
npm ERR! 403 403 Forbidden - GET https://artifactory.XYZ.domain:443/artifactory/api/npm/npm-main/ansi-regex/-/ansi-regex-4.1.0.tgz
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy.
npm ERR! 403
npm ERR! 403 It was specified as a dependency of 'wrap-ansi'
Sure enough, when I look in Artifactory I can see that v4.0.1 is blocked due to a security vulnerability. What are my options here please? Is it possible to somehow force create-react-to instead use a later version without the vulnerability (looks like v5.0.1 is fine)?
Thanks for your help
you can do
npm config set registry <path/to/artifactory>
///create your react project:- npm create-react-app myapp
//then revert to older config if you want to by
npm config delete registry
let me know if it works

(error) AWS as backend installing amplify libraries

I am new to backend. Just starting to make a To-Do app in react and was just setting up amazon aws for backend. Using this site for reference ( https://docs.amplify.aws/start/getting-started/setup/q/integration/react#initialize-a-new-backend ).
And at the point Install Amplify libraries I got stuck while i type npm install aws-amplify #aws-amplify/ui-react in root directory it shows me error everytime.[error pic][1] I am trying for a long but did not find any solution. Pls help me in this issue !!
[1]: https://i.stack.imgur.com/hrSeJ.png Here is the error i'm getting in command prompt👇
npm ERR! Unexpected end of JSON input while parsing near '...:"^1.0.0-beta.2","#aw'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Aakash~1Bansal\AppData\Roaming\npm-cache\_logs\2021-04-09T11_41_43_000Z-debug.log
F:\Learning- tanay pratap\AWS\react-amplified>npm install aws-amplify #aws-amplify/ui-react
npm ERR! Unexpected end of JSON input while parsing near '...:"^1.0.0-beta.2","#aw'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Aakash~1Bansal\AppData\Roaming\npm-cache\_logs\2021-04-09T11_45_14_875Z-debug.log
F:\Learning- tanay pratap\AWS\react-amplified>
I was having the same issue. 1st make sure your PC is connected to internet connection. Run:
npm uninstall -g #aws-amplify/cli
npm install -g #aws-amplify/cli
If possible don't minimize the window wait till everything is properly install.
This worked for me.
Still you are facing problems then reinstall node.js and then do this.
Thank you!

npm Unable to Install angular-cli

I am trying to install angular-cli via npm. I have the recent version of Nodejs and git installed. I am not behind any proxy server(verified it through netsh winhttp show proxy as well as through Internet Explorer LAN settings) and there is no problem with my internet connection. When i try to run
npm install -g angular-cli then I get the following error
C:\Windows\system32>npm install -g angular-cli
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "angular-cli"
npm ERR! node v7.3.0
npm ERR! npm v3.10.10
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! syscall connect
npm ERR! network connect ETIMEDOUT 151.101.192.162:80
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settin
gs.
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! Please include the following file with any support request:
npm ERR! C:\Windows\system32\npm-debug.log
I tried cleaning the cache through npm cache clean and also tried to change the registry to http:\ via
npm config set registry http://registry.npmjs.org/
I also tried uninstalling nodejs and reinstalling it again but it is not working. I am getting the same error. Any ideas.
Setp-1: open windows command prompt then type following command to get the IP address of your proxy server
ping your-proxy-name
For example:
ping myproxy.xyz.com
Step-2: open Node.js command prompt and type following command
npm config set http-proxy http://your-proxy-ip-retrieved-in-step-1:port
npm config set https-proxy http://your-proxy-ip-retrieved-in-step-1:port
For example:
npm config set http-proxy http://192.168.192.95:8080
npm config set https-proxy http://192.168.192.95:8080
Setp-3: on Node.js command prompt type following command to install angular
npm install -g #angular/cli
Hope it will work for you.
Yes, this can be caused either by a firewall or a proxy. Can you ping the npm registry host and fetch a simple file?
> ping registry.npmjs.org
> npm view npm version
If the ping is not successful, check your connection or disable your firewall.
Future viewers: Try below approach (it worked for me)
Go to nodejs installed location (path may be different in your case)
C:\Program Files\nodejs\node_modules\npm
Add below entry in the npmrc file then save it
strict-ssl=false
Then try installing angular cli
npm install -g #angular/cli
This kind of issues usually happen when you are behind a proxy or a firewall that blocks npm from fetching the requested packaged.
If you know your proxy address and port, open a console and set your HTTP_PROXY and HTTPS_PROXY variables before running npm, as follows:
set HTTP_PROXY = "http://<proxy server name or IP address>:<proxy port>"
set HTTPS_PROXY = ... ;same as above
npm install <package_name>
I faced similar issues and figured that we need to combine the proxy and the install command together like below and it worked for me. Hope it works for you people. Thanks!!
npm --proxy http://username:password#proxyURL:port install -g #angular/cli --without-ssl --insecure
You need to override your proxy settings to install angular CLI.
Try executing below command :
npm config set registry http://registry.npmjs.org/
This will override your proxy and you do not need to make any changes to your connections or firewall. Once this command executes successfully try installing angular CLI using below command:
npm install -g #angular/cli
Refer this link for more details on this.
This solved problems for me. Hope this helps!

Error : getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443

I am working on a corporate network.
Trying to install npm. But I'm getting this error again and again.
$ npm install
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v6.1.0
npm ERR! npm v3.8.6
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo
npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is 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! Please include the following file with any support request:
npm ERR! C:\Angular-test\angular-phonecat\npm-debug.log
Tried this also: npm config set registry https://registry.npmjs.org/
Still getting the same error.
Things to try:
make sure you have internet connection: ping 8.8.8.8
make sure you have DNS resolver working: ping www.google.com
make sure you can access registry.npmjs.org: ping registry.npmjs.org
make sure you can connect via https.
Try in your browser: https://registry.npmjs.org/
Make sure you are trying to connect to:
registry.npmjs.org
and not to:
"registry.npmjs.org registry.npmjs.org:443"
or some other weird string composed of few hostnames, because it's weird that the resolver complains about a hostnames that includes a port number, which it shouldn't care about. Ok, I tested and it should look like this for hosts that are not found.
Update
From your comment to this answer it seems that you are not directly connected to the internet if you can't even ping 8.8.8.8.
If you are using a proxy to access the Web, then you also have to configure npm to use it. Use:
npm config set proxy http://example.com:8080
npm config set https-proxy http://example.com:8080
but instead of http://example.com:8080 use what you actually need in your company - ask someone or see how your browser is configured.
To see your proxy configuration in Chrome, see this.
Update 2
If you can access https://registry.npmjs.org/ in your browser but you cannot run ping registry.npmjs.org then it means that your browser must be configured to use a proxy, or other programs than your browser must be restricted from using the internet.
In any case, you should ask someone in your company about it because most likely you either need to use a specific proxy or someone needs to lift the restriction from your npm and allow it to access the network.
The network access can be blocked by a firewall installed on your computer or a router in your network. It's hard to say without knowing the specific configuration in your company.
Update 3
Remove the environment variable "https_proxy" if any or use correct value for "https_proxy"
use: https://registry.npmjs.org/
Make sure you are trying to connect to:
registry.npmjs.org
if there is no error,try to clear cache
npm cache clean --force
then try
npm install
even you have any error
npm config set registry https://registry.npmjs.org/
then try
npm install -g #angular/cli
I tried many but this worked fine for me.
npm config rm proxy
npm config rm https-proxy
above 2 commands is enough if it doesn't work try this as well.
npm config --global rm proxy
npm config --global rm https-proxy
First, edit NetworkManager.conf file:
vim /etc/NetworkManager/NetworkManager.conf
Comment this line:
#dns=dnsmasq
Finally
sudo service network-manager restart
sudo service docker restart
You can use this command
npm config delete proxy
It happens because formidable is prone to severity vulnerability. So, you need to override that by running the above command.
If you are working behind proxy you must set proxy for npm to connect it to repo.
npm config set registry http://registry.npmjs.org/
npm config set proxy http://myusername:mypassword#proxy.somecompany.com:8080
npm config set https-proxy http://myusername:mypassword#proxy.somecompany.com:8080
npm config set strict-ssl false
set HTTPS_PROXY=http://myusername:mypassword#proxy.somecompany.com:8080
set HTTP_PROXY=http://myusername:mypassword#proxy.somecompany.com:8080
Note If your password contains special character like # EX: password : mypwd1#xyz
then use %40 in place of # Ex:
npm config set proxy http://myusername:mypwd1%40xyz#proxy.somecompany.com:8080
npm config set registry https://registry.npmjs.org/
this is the only solution for me.
In my case very alike error (ENOTFOUND registry.npmjs.org) was fixed by adding --no-bin-links to npm install command.
Wierd but might help someone.
If Ubuntu try opening
All Settings > Network > Network proxy
set the method to automatic and save.
I had the same issue. The reason was the corporate proxy issue.
Solution was to set the proxy setting as #rsp says.
npm config set proxy http://example.com:8080
npm config set https-proxy http://example.com:8080
But later I face the same issue. This time reason was my password contains a special character.
In this command you can’t provide a password with special character
. So solution is to provide percentage encoded special character in the password.
For example # has to provide as %23
https://www.w3schools.com/tags/ref_urlencode.asp
I spent over 5 hours trying to get rid of this message under Windows 8.1. So I would like to share my case and save someones time. I was not behind the proxy... but setting proxy helped to resolve the problem. So I go deep and found that issue was caused by Comodo Firewall... which blocked cmd since I was installing packages too fast (turning off and even closing Firewall did not help, which caused me so long to find the issue... seems like there was some other process of Firewall running in background). You may have same issue with any other firewall/antivirus installed so make sure that cmd is not blocked by them. Good luck!
in my case it was just an intermittent issues it seems, didn't work for a few tries, then looked at https://registry.npmjs.org (webpage worked fine), tried again, tried again and then it worked.
For Windows Subsystem Linux:
Restarting my WSL terminal (bash/shell) fixed the issue (it took a few restarts and minutes, however).
use nslookup www.google.com
or npm.org to check connectivity.
First you need to use this command
npm config set registry https://registry.your-registry.npme.io/
This we are doing to set our companies Enterprise registry as our default registry.
You can try other given solutions also.
Most of the time this issue occurs if you are using the system provided by your organization and you are connected to its vpn.
In this case, disconnect from the vpn and then try executing this command.
npm config rm proxy
npm config rm https-proxy
npm config set registry https://registry.npmjs.org/
These 3 commands one after the other worked for me.
Running sudo service docker restart was the key for me! Prior to running this command, I was able to access the npm registry using ping and the browser.

Resources