繁体   English   中英

npx create-react-app projectName 导致错误

[英]npx create-react-app projectName causing error

我正在使用第一个命令创建一个反应应用程序; npm init然后是第二个 npx npx create-react-app projectName ,但是它给出了这个错误:

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.22.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\amrish patidar\AppData\Roaming\npm-cache\_logs\2020-12-17T07_28_05_673Z-debug.log

我的 npm 配置列表如下

npm config list

    ; cli configs
    metrics-registry = "http://registry.npmjs.org/"
    scope = ""
    user-agent = "npm/6.14.9 node/v14.15.2 win32 x64"
    
    ; userconfig C:\Users\amrish patidar\.npmrc
    registry = "http://registry.npmjs.org/"
    strict-ssl = true
    
    ; builtin config undefined
    prefix = "C:\\Users\\amrish patidar\\AppData\\Roaming\\npm"
    
    ; node bin location = C:\Program Files\nodejs\node.exe
    ; cwd = C:\Users\amrish patidar
    ; HOME = C:\Users\amrish patidar
    ; "npm config ls -l" to show all defaults.

调试日志文件

 C:\Users\amrish patidar\AppData\Roaming\npm-cache\_logs\2020-12-17T07_28_05_673Z-debug.log


    0 info it worked if it ends with ok
    1 verbose cli [
    1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
    1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
    1 verbose cli   'install',
    1 verbose cli   'create-react-app'
    1 verbose cli ]
    2 info using npm@6.14.9
    3 info using node@v14.15.2
    4 verbose config Skipping project config: C:\Users\amrish patidar/.npmrc. (matches userconfig)
    5 verbose npm-session c45391ce1f743672
    6 silly install loadCurrentTree
    7 silly install readLocalPackageData
    8 silly fetchPackageMetaData error for create-react-app@latest request to http://registry.npmjs.org/create-react-app failed, reason: connect ETIMEDOUT 104.16.17.35:80
    9 timing stage:rollbackFailedOptional Completed in 1ms
    10 timing stage:runTopLevelLifecycles Completed in 133456ms
    11 verbose type system
    12 verbose stack FetchError: request to http://registry.npmjs.org/create-react-app failed, reason: connect ETIMEDOUT 104.16.17.35:80
    12 verbose stack     at ClientRequest.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
    12 verbose stack     at ClientRequest.emit (events.js:315:20)
    12 verbose stack     at Socket.socketErrorListener (_http_client.js:469:9)
    12 verbose stack     at Socket.emit (events.js:315:20)
    12 verbose stack     at emitErrorNT (internal/streams/destroy.js:106:8)
    12 verbose stack     at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    12 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:80:21)
    13 verbose cwd C:\Users\amrish patidar
    14 verbose Windows_NT 10.0.19041
    15 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "create-react-app"
    16 verbose node v14.15.2
    17 verbose npm  v6.14.9
    18 error code ETIMEDOUT
    19 error errno ETIMEDOUT
    20 error network request to http://registry.npmjs.org/create-react-app failed, reason: connect ETIMEDOUT 104.16.17.35:80
    21 error network This is a problem related to network connectivity.
    21 error network In most cases you are behind a proxy or have bad network settings.
    21 error network
    21 error network If you are behind a proxy, please make sure that the
    21 error network 'proxy' config is set properly.  See: 'npm help config'
    22 verbose exit [ 1, true ]

也许你背后有一些代理,

试试这个

go 到设置>网络和 Internet>代理,然后关闭自动检测 Windows 上的自动代理设置下的设置。 然后它应该可以正常工作

go 通过@Amit K Khanchandani 的所有评论。 可能对您的情况有所帮助。

首先卸载nodejs和npm。 接下来安装两者的最新版本。 如果您收到 package.json 文件不存在的错误,则比运行 npx create-react-app projectname 。 非常重要的一点:“”如果它包含空格,请检查您的系统用户名,而不是问题的原因。 由于用户名中存在空格,您不能使用 cmd npx create-react-app 项目名称。

使用这个 cmd: npm install -g create-react-app(only once) 现在您可以使用 npx create-react-app projectname 创建项目

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM