【发布时间】:2020-09-25 17:48:50
【问题描述】:
我已经尝试清除缓存,但它没有解决我的问题。它工作到几个小时前。之后我在我的另一个项目中使用了npm run eject。之后我收到此错误。我将附上一个错误文件和日志。有人可以帮我吗?
错误
Creating a new React app in F:\React Learning\meals\meal-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/react failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org: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! A complete log of this run can be found in:
npm ERR! C:\Users\pcmaster\AppData\Roaming\npm-cache\_logs\2020-06-06T14_53_15_643Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting meal-app/ from F:\React Learning\meals
Done.
F:\React Learning\meals>
生成的日志文件
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 '--save',
1 verbose cli '--save-exact',
1 verbose cli '--loglevel',
1 verbose cli 'error',
1 verbose cli 'react',
1 verbose cli 'react-dom',
1 verbose cli 'react-scripts',
1 verbose cli 'cra-template' ]
2 info using npm@6.9.0
3 info using node@v10.16.3
4 verbose npm-session bb041aca5c7d9fbf
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData error for react@latest request to https://registry.npmjs.org/react failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
8 silly fetchPackageMetaData error for react-dom@latest request to https://registry.npmjs.org/react-dom failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
9 silly fetchPackageMetaData error for react-scripts@latest request to https://registry.npmjs.org/react-scripts failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
10 silly fetchPackageMetaData error for cra-template@latest request to https://registry.npmjs.org/cra-template failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
11 timing stage:rollbackFailedOptional Completed in 3ms
12 timing stage:runTopLevelLifecycles Completed in 363ms
13 verbose type system
14 verbose stack FetchError: request to https://registry.npmjs.org/react failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
14 verbose stack at ClientRequest.req.on.err (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
14 verbose stack at ClientRequest.emit (events.js:198:13)
14 verbose stack at TLSSocket.socketErrorListener (_http_client.js:392:9)
14 verbose stack at TLSSocket.emit (events.js:198:13)
14 verbose stack at emitErrorNT (internal/streams/destroy.js:91:8)
14 verbose stack at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
14 verbose stack at process._tickCallback (internal/process/next_tick.js:63:19)
15 verbose cwd F:\React Learning\meals\meal-app
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "--save-exact" "--loglevel" "error" "react" "react-dom" "react-scripts" "cra-template"
18 verbose node v10.16.3
19 verbose npm v6.9.0
20 error code ENOTFOUND
21 error errno ENOTFOUND
22 error network request to https://registry.npmjs.org/react failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
23 error network This is a problem related to network connectivity.
23 error network In most cases you are behind a proxy or have bad network settings.
23 error network
23 error network If you are behind a proxy, please make sure that the
23 error network 'proxy' config is set properly. See: 'npm help config'
24 verbose exit [ 1, true ]
我是新来的反应。我使用相同的命令创建了一个反应多反应应用程序。但不知道为什么这次它不起作用。我有一个更新的 nodejs。
【问题讨论】:
-
尝试在网络浏览器上打开“registry.npmjs.org/react”时会得到什么?
-
你连接到互联网了吗?
-
你在代理后面吗?
-
你遵循了哪些步骤来创建新的 React 项目?您不应该全局安装
create-react-app。检查stackoverflow.com/a/62122386/2873538 的步骤。 -
@AjeetShah 非常感谢。它解决了我的问题。
标签: reactjs react-native npm react-redux node-modules