PS C:\Users\Khldon\Desktop\react bascs> npx create-react-app my-app
Creating a new React app in C:\Users\Khldon\Desktop\react bascs\my-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-config-react-app: 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\Khldon\AppData\Local\npm-cache\_logs\2022-03-10T18_23_30_605Z-debug.log
Aborting installation.
npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting my-app/ from C:\Users\Khldon\Desktop\react bascs
Done.
node-v:16.14.0
我不使用代理,我已经尝试了每一个单一的解决方案在互联网上,仍然有同样的错误
我也尝试了这个线程中的每一个解决方案:npm not working - "read ECONNRESET"
下面是我的日志文件的最后几行,我认为它们表明了问题所在:
3521 http fetch GET 200 https://registry.npmjs.org/lodash.sortby 261ms (cache miss)
3522 http fetch GET 200 https://registry.npmjs.org/webidl-conversions 494ms (cache miss)
3523 http fetch GET 200 https://registry.npmjs.org/tr46 534ms (cache miss)
3524 timing idealTree:node_modules/workbox-build/node_modules/source-map Completed in 540ms
3525 silly placeDep ROOT lodash.sortby@4.7.0 OK for: whatwg-url@7.1.0 want: ^4.7.0
3526 silly placeDep ROOT tr46@1.0.1 OK for: whatwg-url@7.1.0 want: ^1.0.1
3527 silly placeDep ROOT webidl-conversions@4.0.2 OK for: whatwg-url@7.1.0 want: ^4.0.2
3528 timing idealTree:node_modules/whatwg-url Completed in 5ms
3529 timing idealTree:node_modules/lodash.sortby Completed in 0ms
3530 timing idealTree:node_modules/tr46 Completed in 0ms
3531 timing idealTree:node_modules/webidl-conversions Completed in 0ms
3532 silly placeDep node_modules/workbox-webpack-plugin source-map@0.6.1 OK for: webpack-sources@1.4.3 want: ~0.6.1
3533 timing idealTree:node_modules/workbox-webpack-plugin/node_modules/webpack-sources Completed in 2ms
3534 timing idealTree:node_modules/workbox-webpack-plugin/node_modules/source-map Completed in 0ms
3535 timing idealTree:buildDeps Completed in 5489589ms
3536 timing idealTree:fixDepFlags Completed in 35ms
3537 timing idealTree Completed in 5489651ms
3538 timing command:install Completed in 5489669ms
3539 verbose type system
3540 verbose stack FetchError: request to http://registry.npmjs.org/js-tokens failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org
3540 verbose stack at ClientRequest.<anonymous> (C:\Users\Khldon\AppData\Roaming\nvm\v16.13.0\node_modules\npm\node_modules\minipass-fetch\lib\index.js:110:14)
3540 verbose stack at ClientRequest.emit (node:events:390:28)
3540 verbose stack at Socket.socketErrorListener (node:_http_client:447:9)
3540 verbose stack at Socket.emit (node:events:402:35)
3540 verbose stack at emitErrorNT (node:internal/streams/destroy:157:8)
3540 verbose stack at emitErrorCloseNT (node:internal/streams/destroy:122:3)
3540 verbose stack at processTicksAndRejections (node:internal/process/task_queues:83:21)
3541 verbose cwd C:\Users\Khldon\Desktop\react bascs\my-app
3542 verbose Windows_NT 10.0.19042
3543 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--no-audit" "--save" "--save-exact" "--loglevel" "error" "react" "react-dom" "react-scripts" "cra-template"
3544 verbose node v16.13.0
3545 verbose npm v8.1.0
3546 error code ENOTFOUND
3547 error syscall getaddrinfo
3548 error errno ENOTFOUND
3549 error network request to http://registry.npmjs.org/js-tokens failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org
3550 error network This is a problem related to network connectivity.
3550 error network In most cases you are behind a proxy or have bad network settings.
3550 error network
3550 error network If you are behind a proxy, please make sure that the
3550 error network 'proxy' config is set properly. See: 'npm help config'
3551 verbose exit 1
2条答案
按热度按时间yzuktlbb1#
有一些错误的连接到网站你可以来下面这个链接来解决问题https://www.codeproject.com/Questions/5258241/How-to-resolve-NPM-proxy-issue-whilel-running-node
然后通过npx create-react-app myfile重新安装npm。它可能会问你是否要安装“create-react-app”,只需按Enter键。
vnzz0bqm2#
参见:https://www.jhipster.tech/configuring-a-corporate-proxy
使用以下命令: