我安装了 nodejs 和 npm 我尝试运行命令
npm install -g create-react-app
但它停在下面的错误处
freduah@freduah:~$ npm install -g create-react-app
npm WARN registry Unexpected warning for http://registry.npmjs.org/: Miscellaneous Warning EAI_AGAIN: request to http://registry.npmjs.org/create-react-app failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org
npm WARN registry Using stale data from http://registry.npmjs.org/ due to a request error during revalidation.
npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at http://registry.npmjs.org/ansi-escapes reason: Unexpected end of JSON input
npm ERR! A complete log of this run can be found in:
npm ERR! /home/freduah/.npm/_logs/2020-10-31T19_11_20_727Z-debug.log
freduah@freduah:~$
Run Code Online (Sandbox Code Playgroud)
以下是完整的错误日志内容
freduah@freduah:~/Downloads$ cat /home/freduah/.npm/_logs/2020-10-31T19_11_20_727Z-debug.log
0 verbose cli [
0 verbose cli '/usr/bin/node',
0 verbose cli '/usr/bin/npm',
0 verbose cli 'install',
0 verbose cli '-g',
0 verbose cli 'create-react-app'
0 verbose cli ]
1 info using npm@7.0.3
2 info using node@v12.19.0
3 timing config:load:defaults Completed in 2ms
4 timing config:load:file:/usr/share/npm/npmrc Completed in 3ms
5 timing config:load:builtin Completed in 3ms
6 timing config:load:cli Completed in 4ms
7 timing config:load:env Completed in 0ms
8 timing config:load:project Completed in 1ms
9 timing config:load:file:/home/freduah/.npmrc Completed in 1ms
10 timing config:load:user Completed in 1ms
11 timing config:load:file:/etc/npmrc Completed in 0ms
12 timing config:load:global Completed in 0ms
13 timing config:load:cafile Completed in 0ms
14 timing config:load:validate Completed in 2ms
15 timing config:load:setUserAgent Completed in 1ms
16 timing config:load:setEnvs Completed in 1ms
17 timing config:load Completed in 15ms
18 verbose npm-session 3fe07c2ad8478ec0
19 timing npm:load Completed in 27ms
20 timing arborist:ctor Completed in 1ms
21 timing idealTree:init Completed in 3ms
22 timing idealTree:userRequests Completed in 8ms
23 silly idealTree buildDeps
24 silly fetch manifest create-react-app@*
25 warn registry Unexpected warning for http://registry.npmjs.org/: Miscellaneous Warning EAI_AGAIN: request to http://registry.npmjs.org/create-react-app failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org
26 warn registry Using stale data from http://registry.npmjs.org/ due to a request error during revalidation.
27 http fetch GET 200 http://registry.npmjs.org/create-react-app 10087ms (from cache)
28 silly placeDep ROOT create-react-app@4.0.0 OK for: want: *
29 silly fetch manifest chalk@4.1.0
30 silly fetch manifest commander@4.1.1
31 silly fetch manifest cross-spawn@7.0.3
32 silly fetch manifest envinfo@7.7.3
33 silly fetch manifest fs-extra@9.0.1
34 silly fetch manifest hyperquest@2.1.3
35 silly fetch manifest inquirer@7.3.3
36 silly fetch manifest semver@7.3.2
37 silly fetch manifest tar-pack@3.4.1
38 silly fetch manifest tmp@0.2.1
39 silly fetch manifest validate-npm-package-name@3.0.0
40 http fetch GET 304 http://registry.npmjs.org/envinfo 23286ms (from cache)
41 http fetch GET 304 http://registry.npmjs.org/cross-spawn 23292ms (from cache)
42 http fetch GET 304 http://registry.npmjs.org/fs-extra 23665ms (from cache)
43 http fetch GET 304 http://registry.npmjs.org/hyperquest 24552ms (from cache)
44 http fetch GET 304 http://registry.npmjs.org/semver 28953ms (from cache)
45 http fetch GET 304 http://registry.npmjs.org/inquirer 28960ms (from cache)
46 http fetch GET 304 http://registry.npmjs.org/tar-pack 29245ms (from cache)
47 http fetch GET 304 http://registry.npmjs.org/tmp 29303ms (from cache)
48 http fetch GET 304 http://registry.npmjs.org/validate-npm-package-name 30877ms (from cache)
49 http fetch GET 304 http://registry.npmjs.org/chalk 36204ms attempt #2 (from cache)
50 http fetch GET 304 http://registry.npmjs.org/commander 36204ms attempt #2 (from cache)
51 timing idealTree:#root Completed in 46313ms
52 silly placeDep node_modules/create-react-app chalk@4.1.0 OK for: create-react-app@4.0.0 want: 4.1.0
53 silly placeDep node_modules/create-react-app commander@4.1.1 OK for: create-react-app@4.0.0 want: 4.1.1
54 silly placeDep node_modules/create-react-app cross-spawn@7.0.3 OK for: create-react-app@4.0.0 want: 7.0.3
55 silly placeDep node_modules/create-react-app envinfo@7.7.3 OK for: create-react-app@4.0.0 want: 7.7.3
56 silly placeDep node_modules/create-react-app fs-extra@9.0.1 OK for: create-react-app@4.0.0 want: 9.0.1
57 silly placeDep node_modules/create-react-app hyperquest@2.1.3 OK for: create-react-app@4.0.0 want: 2.1.3
58 silly placeDep node_modules/create-react-app inquirer@7.3.3 OK for: create-react-app@4.0.0 want: 7.3.3
59 silly placeDep node_modules/create-react-app semver@7.3.2 OK for: create-react-app@4.0.0 want: 7.3.2
60 silly placeDep node_modules/create-react-app tar-pack@3.4.1 OK for: create-react-app@4.0.0 want: 3.4.1
61 silly placeDep node_modules/create-react-app tmp@0.2.1 OK for: create-react-app@4.0.0 want: 0.2.1
62 silly placeDep node_modules/create-react-app validate-npm-package-name@3.0.0 OK for: create-react-app@4.0.0 want: 3.0.0
63 silly fetch manifest ansi-styles@^4.1.0
64 silly fetch manifest supports-color@^7.1.0
65 silly fetch manifest path-key@^3.1.0
66 silly fetch manifest shebang-command@^2.0.0
67 silly fetch manifest which@^2.0.1
68 silly fetch manifest at-least-node@^1.0.0
69 silly fetch manifest graceful-fs@^4.2.0
70 silly fetch manifest jsonfile@^6.0.1
71 silly fetch manifest universalify@^1.0.0
72 silly fetch manifest buffer-from@^0.1.1
73 silly fetch manifest duplexer2@~0.0.2
74 silly fetch manifest through2@~0.6.3
75 silly fetch manifest ansi-escapes@^4.2.1
76 silly fetch manifest cli-cursor@^3.1.0
77 silly fetch manifest cli-width@^3.0.0
78 silly fetch manifest external-editor@^3.0.3
79 silly fetch manifest figures@^3.0.0
80 silly fetch manifest lodash@^4.17.19
81 silly fetch manifest mute-stream@0.0.8
82 silly fetch manifest run-async@^2.4.0
83 silly fetch manifest rxjs@^6.6.0
84 silly fetch manifest string-width@^4.1.0
85 silly fetch manifest strip-ansi@^6.0.0
86 silly fetch manifest through@^2.3.6
87 silly fetch manifest debug@^2.2.0
88 silly fetch manifest fstream@^1.0.10
89 silly fetch manifest fstream-ignore@^1.0.5
90 silly fetch manifest once@^1.3.3
91 silly fetch manifest readable-stream@^2.1.4
92 silly fetch manifest rimraf@^2.5.1
93 silly fetch manifest tar@^2.2.1
94 silly fetch manifest uid-number@^0.0.6
95 silly fetch manifest rimraf@^3.0.0
96 silly fetch manifest builtins@^1.0.3
97 http fetch GET 200 http://registry.npmjs.org/jsonfile 240ms (from cache)
98 http fetch GET 304 http://registry.npmjs.org/ansi-styles 1807ms (from cache)
99 http fetch GET 304 http://registry.npmjs.org/supports-color 1806ms (from cache)
100 http fetch GET 304 http://registry.npmjs.org/which 1866ms (from cache)
101 http fetch GET 304 http://registry.npmjs.org/path-key 1893ms (from cache)
102 http fetch GET 304 http://registry.npmjs.org/at-least-node 1933ms (from cache)
103 http fetch GET 304 http://registry.npmjs.org/graceful-fs 1974ms (from cache)
104 http fetch GET 304 http://registry.npmjs.org/cli-cursor 2773ms (from cache)
105 http fetch GET 304 http://registry.npmjs.org/cli-width 2804ms (from cache)
106 http fetch GET 304 http://registry.npmjs.org/external-editor 2929ms (from cache)
107 http fetch GET 304 http://registry.npmjs.org/mute-stream 2956ms (from cache)
108 http fetch GET 304 http://registry.npmjs.org/lodash 2960ms (from cache)
109 http fetch GET 304 http://registry.npmjs.org/figures 3064ms (from cache)
110 http fetch GET 304 http://registry.npmjs.org/run-async 3500ms (from cache)
111 http fetch GET 304 http://registry.npmjs.org/rxjs 3522ms (from cache)
112 http fetch GET 304 http://registry.npmjs.org/string-width 3555ms (from cache)
113 http fetch GET 304 http://registry.npmjs.org/universalify 3677ms (from cache)
114 http fetch GET 304 http://registry.npmjs.org/buffer-from 3687ms (from cache)
115 http fetch GET 304 http://registry.npmjs.org/strip-ansi 3660ms (from cache)
116 http fetch GET 304 http://registry.npmjs.org/through 3681ms (from cache)
117 http fetch GET 304 http://registry.npmjs.org/debug 3784ms (from cache)
118 http fetch GET 304 http://registry.npmjs.org/fstream 4015ms (from cache)
119 http fetch GET 304 http://registry.npmjs.org/duplexer2 4169ms (from cache)
120 http fetch GET 304 http://registry.npmjs.org/through2 4179ms (from cache)
121 http fetch GET 304 http://registry.npmjs.org/fstream-ignore 4133ms (from cache)
122 http fetch GET 304 http://registry.npmjs.org/readable-stream 4169ms (from cache)
123 http fetch GET 304 http://registry.npmjs.org/rimraf 4200ms (from cache)
124 http fetch GET 304 http://registry.npmjs.org/uid-number 4526ms (from cache)
125 http fetch GET 304 http://registry.npmjs.org/builtins 4520ms (from cache)
126 http fetch GET 304 http://registry.npmjs.org/rimraf 4536ms (from cache)
127 http fetch GET 304 http://registry.npmjs.org/ansi-escapes 4660ms (from cache)
128 http fetch GET 304 http://registry.npmjs.org/tar 4601ms (from cache)
129 http fetch GET 304 http://registry.npmjs.org/shebang-command 5758ms (from cache)
130 http fetch GET 304 http://registry.npmjs.org/once 9981ms (from cache)
131 timing idealTree:node_modules/create-react-app Completed in 10102ms
132 silly placeDep node_modules/create-react-app ansi-styles@4.3.0 OK for: chalk@4.1.0 want: ^4.1.0
133 silly placeDep node_modules/create-react-app supports-color@7.2.0 OK for: chalk@4.1.0 want: ^7.1.0
134 silly fetch manifest color-convert@^2.0.1
135 silly fetch manifest has-flag@^4.0.0
136 http fetch GET 304 http://registry.npmjs.org/has-flag 4131ms (from cache)
137 http fetch GET 304 http://registry.npmjs.org/color-convert 4168ms (from cache)
138 timing idealTree:node_modules/create-react-app/node_modules/chalk Completed in 4176ms
139 silly placeDep node_modules/create-react-app color-convert@2.0.1 OK for: ansi-styles@4.3.0 want: ^2.0.1
140 silly fetch manifest color-name@~1.1.4
141 http fetch GET 304 http://registry.npmjs.org/color-name 3286ms (from cache)
142 timing idealTree:node_modules/create-react-app/node_modules/ansi-styles Completed in 3291ms
143 silly placeDep node_modules/create-react-app color-name@1.1.4 OK for: color-convert@2.0.1 want: ~1.1.4
144 timing idealTree:node_modules/create-react-app/node_modules/color-convert Completed in 2ms
145 timing idealTree:node_modules/create-react-app/node_modules/color-name Completed in 0ms
146 timing idealTree:node_modules/create-react-app/node_modules/commander Completed in 0ms
147 silly placeDep node_modules/create-react-app path-key@3.1.1 OK for: cross-spawn@7.0.3 want: ^3.1.0
148 silly placeDep node_modules/create-react-app shebang-command@2.0.0 OK for: cross-spawn@7.0.3 want: ^2.0.0
149 silly placeDep node_modules/create-react-app which@2.0.2 OK for: cross-spawn@7.0.3 want: ^2.0.1
150 silly fetch manifest shebang-regex@^3.0.0
151 silly fetch manifest isexe@^2.0.0
152 http fetch GET 304 http://registry.npmjs.org/shebang-regex 1543ms (from cache)
153 http fetch GET 304 http://registry.npmjs.org/isexe 2212ms (from cache)
154 timing idealTree:node_modules/create-react-app/node_modules/cross-spawn Completed in 2223ms
155 timing idealTree:node_modules/create-react-app/node_modules/envinfo Completed in 0ms
156 silly placeDep node_modules/create-react-app at-least-node@1.0.0 OK for: fs-extra@9.0.1 want: ^1.0.0
157 silly placeDep node_modules/create-react-app graceful-fs@4.2.4 OK for: fs-extra@9.0.1 want: ^4.2.0
158 silly placeDep node_modules/create-react-app jsonfile@6.1.0 OK for: fs-extra@9.0.1 want: ^6.0.1
159 silly placeDep node_modules/create-react-app universalify@1.0.0 OK for: fs-extra@9.0.1 want: ^1.0.0
160 silly fetch manifest universalify@^2.0.0
161 http fetch GET 304 http://registry.npmjs.org/universalify 387ms (from cache)
162 timing idealTree:node_modules/create-react-app/node_modules/fs-extra Completed in 399ms
163 timing idealTree:node_modules/create-react-app/node_modules/at-least-node Completed in 0ms
164 timing idealTree:node_modules/create-react-app/node_modules/graceful-fs Completed in 0ms
165 silly placeDep node_modules/create-react-app buffer-from@0.1.2 OK for: hyperquest@2.1.3 want: ^0.1.1
166 silly placeDep node_modules/create-react-app duplexer2@0.0.2 OK for: hyperquest@2.1.3 want: ~0.0.2
167 silly placeDep node_modules/create-react-app through2@0.6.5 OK for: hyperquest@2.1.3 want: ~0.6.3
168 silly fetch manifest readable-stream@~1.1.9
169 silly fetch manifest readable-stream@>=1.0.33-1 <1.1.0-0
170 silly fetch manifest xtend@>=4.0.0 <4.1.0-0
171 http fetch GET 304 http://registry.npmjs.org/readable-stream 391ms (from cache)
172 http fetch GET 304 http://registry.npmjs.org/readable-stream 468ms (from cache)
173 http fetch GET 304 http://registry.npmjs.org/xtend 568ms (from cache)
174 timing idealTree:node_modules/create-react-app/node_modules/hyperquest Completed in 581ms
175 timing idealTree:node_modules/create-react-app/node_modules/buffer-from Completed in 0ms
176 silly placeDep node_modules/create-react-app readable-stream@1.1.14 OK for: duplexer2@0.0.2 want: ~1.1.9
177 silly fetch manifest core-util-is@~1.0.0
178 silly fetch manifest isarray@0.0.1
179 silly fetch manifest string_decoder@~0.10.x
180 silly fetch manifest inherits@~2.0.1
181 http fetch GET 304 http://registry.npmjs.org/string_decoder 1910ms (from cache)
182 http fetch GET 304 http://registry.npmjs.org/inherits 1923ms (from cache)
183 http fetch GET 304 http://registry.npmjs.org/isarray 2011ms (from cache)
184 http fetch GET 304 http://registry.npmjs.org/core-util-is 2059ms (from cache)
185 timing idealTree:node_modules/create-react-app/node_modules/duplexer2 Completed in 2066ms
186 silly placeDep node_modules/create-react-app ansi-escapes@ OK for: inquirer@7.3.3 want: ^4.2.1
187 silly placeDep node_modules/create-react-app cli-cursor@3.1.0 OK for: inquirer@7.3.3 want: ^3.1.0
188 silly placeDep node_modules/create-react-app cli-width@3.0.0 OK for: inquirer@7.3.3 want: ^3.0.0
189 silly placeDep node_modules/create-react-app external-editor@3.1.0 OK for: inquirer@7.3.3 want: ^3.0.3
190 silly placeDep node_modules/create-react-app figures@3.2.0 OK for: inquirer@7.3.3 want: ^3.0.0
191 silly placeDep node_modules/create-react-app lodash@ OK for: inquirer@7.3.3 want: ^4.17.19
192 silly placeDep node_modules/create-react-app mute-stream@0.0.8 OK for: inquirer@7.3.3 want: 0.0.8
193 silly placeDep node_modules/create-react-app run-async@2.4.1 OK for: inquirer@7.3.3 want: ^2.4.0
194 silly placeDep node_modules/create-react-app rxjs@ OK for: inquirer@7.3.3 want: ^6.6.0
195 silly placeDep node_modules/create-react-app string-width@4.2.0 OK for: inquirer@7.3.3 want: ^4.1.0
196 silly placeDep node_modules/create-react-app strip-ansi@6.0.0 OK for: inquirer@7.3.3 want: ^6.0.0
197 silly placeDep node_modules/create-react-app through@2.3.8 OK for: inquirer@7.3.3 want: ^2.3.6
198 silly fetch manifest restore-cursor@^3.1.0
199 silly fetch manifest chardet@^0.7.0
200 silly fetch manifest iconv-lite@^0.4.24
201 silly fetch manifest tmp@^0.0.33
202 silly fetch manifest escape-string-regexp@^1.0.5
203 silly fetch manifest emoji-regex@^8.0.0
204 silly fetch manifest is-fullwidth-code-point@^3.0.0
205 silly fetch manifest ansi-regex@^5.0.0
206 http fetch GET 304 http://registry.npmjs.org/restore-cursor 2954ms (from cache)
207 http fetch GET 304 http://registry.npmjs.org/iconv-lite 2955ms (from cache)
208 http fetch GET 304 http://registry.npmjs.org/tmp 3027ms (from cache)
209 http fetch GET 304 http://registry.npmjs.org/escape-string-regexp 3040ms (from cache)
210 http fetch GET 304 http://registry.npmjs.org/emoji-regex 3054ms (from cache)
211 http fetch GET 304 http://registry.npmjs.org/chardet 3129ms (from cache)
212 http fetch GET 304 http://registry.npmjs.org/is-fullwidth-code-point 5774ms (from cache)
213 http fetch GET 304 http://registry.npmjs.org/ansi-regex 5811ms (from cache)
214 timing idealTree:node_modules/create-react-app/node_modules/inquirer Completed in 5883ms
215 timing idealTree:node_modules/create-react-app/node_modules/ansi-escapes Completed in 0ms
216 silly placeDep node_modules/create-react-app restore-cursor@3.1.0 OK for: cli-cursor@3.1.0 want: ^3.1.0
217 silly fetch manifest onetime@^5.1.0
218 silly fetch manifest signal-exit@^3.0.2
219 http fetch GET 304 http://registry.npmjs.org/onetime 1230ms (from cache)
220 http fetch GET 304 http://registry.npmjs.org/signal-exit 1276ms (from cache)
221 timing idealTree:node_modules/create-react-app/node_modules/cli-cursor Completed in 1282ms
222 timing idealTree:node_modules/create-react-app/node_modules/cli-width Completed in 0ms
223 silly placeDep node_modules/create-react-app chardet@0.7.0 OK for: external-editor@3.1.0 want: ^0.7.0
224 silly placeDep node_modules/create-react-app iconv-lite@0.4.24 OK for: external-editor@3.1.0 want: ^0.4.24
225 silly placeDep node_modules/create-react-app/node_modules/external-editor tmp@0.0.33 OK for: external-editor@3.1.0 want: ^0.0.33
226 silly fetch manifest safer-buffer@>= 2.1.2 < 3
227 silly fetch manifest os-tmpdir@~1.0.2
228 http fetch GET 304 http://registry.npmjs.org/os-tmpdir 770ms (from cache)
229 http fetch GET 304 http://registry.npmjs.org/safer-buffer 783ms (from cache)
230 timing idealTree:node_modules/create-react-app/node_modules/external-editor Completed in 792ms
231 timing idealTree:node_modules/create-react-app/node_modules/chardet Completed in 0ms
232 silly placeDep node_modules/create-react-app escape-string-regexp@1.0.5 OK for: figures@3.2.0 want: ^1.0.5
233 timing idealTree:node_modules/create-react-app/node_modules/figures Completed in 3ms
234 timing idealTree:node_modules/create-react-app/node_modules/escape-string-regexp Completed in 0ms
235 silly placeDep node_modules/create-react-app safer-buffer@2.1.2 OK for: iconv-lite@0.4.24 want: >= 2.1.2 < 3
236 timing idealTree:node_modules/create-react-app/node_modules/iconv-lite Completed in 2ms
237 silly placeDep node_modules/create-react-app/node_modules/jsonfile universalify@2.0.0 OK for: jsonfile@6.1.0 want: ^2.0.0
238 timing idealTree:node_modules/create-react-app/node_modules/jsonfile Completed in 2ms
239 timing idealTree:node_modules/create-react-app/node_modules/lodash Completed in 1ms
240 timing idealTree:node_modules/create-react-app/node_modules/mute-stream Completed in 0ms
241 timing idealTree:node_modules/create-react-app/node_modules/path-key Completed in 0ms
242 silly placeDep node_modules/create-react-app core-util-is@1.0.2 OK for: readable-stream@1.1.14 want: ~1.0.0
243 silly placeDep node_modules/create-react-app inherits@2.0.4 OK for: readable-stream@1.1.14 want: ~2.0.1
244 silly placeDep node_modules/create-react-app isarray@0.0.1 OK for: readable-stream@1.1.14 want: 0.0.1
245 silly placeDep node_modules/create-react-app string_decoder@ OK for: readable-stream@1.1.14 want: ~0.10.x
246 timing idealTree:node_modules/create-react-app/node_modules/readable-stream Completed in 6ms
247 timing idealTree:node_modules/create-react-app/node_modules/core-util-is Completed in 1ms
248 timing idealTree:node_modules/create-react-app/node_modules/inherits Completed in 0ms
249 timing idealTree:node_modules/create-react-app/node_modules/isarray Completed in 0ms
250 silly placeDep node_modules/create-react-app onetime@5.1.2 OK for: restore-cursor@3.1.0 want: ^5.1.0
251 silly placeDep node_modules/create-react-app signal-exit@3.0.3 OK for: restore-cursor@3.1.0 want: ^3.0.2
252 silly fetch manifest mimic-fn@^2.1.0
253 http fetch GET 304 http://registry.npmjs.org/mimic-fn 525ms (from cache)
254 timing idealTree:node_modules/create-react-app/node_modules/restore-cursor Completed in 532ms
255 silly placeDep node_modules/create-react-app mimic-fn@2.1.0 OK for: onetime@5.1.2 want: ^2.1.0
256 timing idealTree:node_modules/create-react-app/node_modules/onetime Completed in 3ms
257 timing idealTree:node_modules/cr
由于一些奇怪的原因,这些答案都没有帮助我。我发现这是我的代理的问题。我按照以下步骤解决了它:
npm 缓存清理 --force
npm 配置 rm 代理
npm config rm https-proxy
npm 缓存验证
删除node_modules文件夹并运行
npm 安装
你可以做:
npm cache clean --force
Run Code Online (Sandbox Code Playgroud)
其实在最新版本中,你不需要清除,你可以:
npm cache verify
Run Code Online (Sandbox Code Playgroud)
当您遇到与代理相关的问题时,就会发生这种情况。我按照以下步骤解决了它:
npm cache clean --force
npm config rm proxy
npm config rm https-proxy
npm cache verify
Run Code Online (Sandbox Code Playgroud)
删除 node_modules 文件夹(如果使用现有包,然后运行以下命令,否则只需在 CLI 中运行以下命令)
npm set registry=https://registry.npmjs.org/
Run Code Online (Sandbox Code Playgroud)
然后再次尝试您安装新软件包或刚刚安装node_modules的任何内容,如果它给您相同的错误,那么我建议您重新启动笔记本电脑并再次运行上述命令
| 归档时间: |
|
| 查看次数: |
14794 次 |
| 最近记录: |