问题
I am executing following command on Windows:
npm install -g create-react-app
However I am getting following error:
npm ERR! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! network request to http://registry.npmjs.org/create-react-app failed, reason: connect ETIMEDOUT 104.16.20.35: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:\Users\faizanmubasher\AppData\Roaming\npm-cache_logs\2019-02-20T13_22_23_493Z-debug.log
Though I have properly set the proxy configurations:
npm config set http-proxy username:password@proxyip:port -g
npm config set proxy username:password@proxyip:port -g
npm config set https-proxy username:password@proxyip:port -g
Also tried this:
npm --proxy username:password@proxyip:port\ install -g create-react-app
- Is there a way to make npm install (the command) to work behind proxy?
- NPM Behind A Proxy Server
- How to use NPM Install (The Command) behind Corporate Proxy Server
I am behind corporate proxy.
回答1:
Could it possibly be a problem with NPM and not the package you are trying to install? You could try this:
npm config delete proxy
回答2:
Try
npx create-react-app my-app
cd my-app
npm start
Creating an App
You’ll need to have Node >= 6 on your local development machine (but it’s not required on the server). You can use nvm (macOS/Linux) or nvm-windows to easily switch Node versions between different projects.
To create a new app, you may choose one of the following methods: npx
npx create-react-app my-app
(npx comes with npm 5.2+ and higher, see instructions for older npm versions) npm
npm init react-app my-app
npm init is available in npm 6+ Yarn
yarn create react-app my-app
yarn create is available in Yarn 0.25+ Output
Running any of these commands will create a directory called my-app inside the current folder. Inside that directory, it will generate the initial project structure and install the transitive dependencies:
my-app ├── README.md ├── node_modules ├── package.json ├── .gitignore ├── public │ ├── favicon.ico │ ├── index.html │ └── manifest.json └── src
├── App.css
├── App.js
├── App.test.js
├── index.css
├── index.js
├── logo.svg
└── serviceWorker.js
No configuration or complicated folder structures, just the files you need to build your app. Once the installation is done, you can open your project folder:
cd my-app
npm start
来源:https://stackoverflow.com/questions/54787536/npm-etimedout-error-while-installing-react