create-react-app

时间:2018-12-11 09:56:20

标签: reactjs npm cmd

我正在学习React。运行时,我在下面的屏幕截图(链接)中遇到了这2个错误:

npm i -g create-react-app@1.5.2
  • 屏幕截图:

https://i.ibb.co/S7yszvz/Capture.png

https://i.ibb.co/4Y7LY6X/Capture2.png

  • 错误:

    [..................] / 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'
    

我尝试过的事情:

  • npm config rm代理
  • npm config rm https-proxy
  • npm配置集注册表http://registry.npmjs.org/
  • npm配置获取https-proxy(返回 null

我希望获得一些帮助,以便我能有所进步。谢谢

2 个答案:

答案 0 :(得分:0)

我终于通过电话网络(必须是防火墙)做到了,但是然后:

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.

答案 1 :(得分:0)

一段时间以前,我也遇到npx create-react-app my-app类似的问题。 因此,我重新安装了NodeJ,然后尝试通过以下命令从npm config中删除代理设置:

  • npm init
  • npm config rm proxy
  • npm config rm https-proxy

,然后再次尝试命令npm i -g create-react-app@X.X.X。 希望这会有所帮助。