npm 错误! http://registry.npmjs.org/ansi-escapes 处的无效 json 响应正文 原因:JSON 输入意外结束

Posted

技术标签:

【中文标题】npm 错误! http://registry.npmjs.org/ansi-escapes 处的无效 json 响应正文 原因:JSON 输入意外结束【英文标题】:npm ERR! invalid json response body at http://registry.npmjs.org/ansi-escapes reason: Unexpected end of JSON input 【发布时间】:2021-02-13 22:17:37 【问题描述】:

我已经安装了 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:~$ 

以下是完整的错误日志内容

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/create-react-app/node_modules/mimic-fn Completed in 0ms
258 timing idealTree:node_modules/create-react-app/node_modules/run-async Completed in 0ms
259 timing idealTree:node_modules/create-react-app/node_modules/rxjs Completed in 0ms
260 timing idealTree:node_modules/create-react-app/node_modules/safer-buffer Completed in 0ms
261 timing idealTree:node_modules/create-react-app/node_modules/semver Completed in 0ms
262 silly placeDep node_modules/create-react-app shebang-regex@3.0.0 OK for: shebang-command@2.0.0 want: ^3.0.0
263 timing idealTree:node_modules/create-react-app/node_modules/shebang-command Completed in 3ms
264 timing idealTree:node_modules/create-react-app/node_modules/shebang-regex Completed in 0ms
265 timing idealTree:node_modules/create-react-app/node_modules/signal-exit Completed in 0ms
266 timing idealTree:node_modules/create-react-app/node_modules/string_decoder Completed in 0ms
267 silly placeDep node_modules/create-react-app emoji-regex@8.0.0 OK for: string-width@4.2.0 want: ^8.0.0
268 silly placeDep node_modules/create-react-app is-fullwidth-code-point@3.0.0 OK for: string-width@4.2.0 want: ^3.0.0
269 timing idealTree:node_modules/create-react-app/node_modules/string-width Completed in 5ms
270 timing idealTree:node_modules/create-react-app/node_modules/emoji-regex Completed in 0ms
271 timing idealTree:node_modules/create-react-app/node_modules/is-fullwidth-code-point Completed in 0ms
272 silly placeDep node_modules/create-react-app ansi-regex@5.0.0 OK for: strip-ansi@6.0.0 want: ^5.0.0
273 timing idealTree:node_modules/create-react-app/node_modules/strip-ansi Completed in 7ms
274 timing idealTree:node_modules/create-react-app/node_modules/ansi-regex Completed in 0ms
275 silly placeDep node_modules/create-react-app has-flag@4.0.0 OK for: supports-color@7.2.0 want: ^4.0.0
276 timing idealTree:node_modules/create-react-app/node_modules/supports-color Completed in 3ms
277 timing idealTree:node_modules/create-react-app/node_modules/has-flag Completed in 0ms
278 silly placeDep node_modules/create-react-app debug@ OK for: tar-pack@3.4.1 want: ^2.2.0
279 silly placeDep node_modules/create-react-app fstream@1.0.12 OK for: tar-pack@3.4.1 want: ^1.0.10
280 silly placeDep node_modules/create-react-app fstream-ignore@1.0.5 OK for: tar-pack@3.4.1 want: ^1.0.5
281 silly placeDep node_modules/create-react-app once@1.4.0 OK for: tar-pack@3.4.1 want: ^1.3.3
282 silly placeDep node_modules/create-react-app/node_modules/tar-pack readable-stream@2.3.7 OK for: tar-pack@3.4.1 want: ^2.1.4
283 silly placeDep node_modules/create-react-app rimraf@ OK for: tar-pack@3.4.1 want: ^2.5.1
284 silly placeDep node_modules/create-react-app tar@ OK for: tar-pack@3.4.1 want: ^2.2.1
285 silly placeDep node_modules/create-react-app uid-number@0.0.6 OK for: tar-pack@3.4.1 want: ^0.0.6
286 silly fetch manifest mkdirp@>=0.5 0
287 silly fetch manifest minimatch@^3.0.0
288 silly fetch manifest wrappy@1
289 silly fetch manifest isarray@~1.0.0
290 silly fetch manifest process-nextick-args@~2.0.0
291 silly fetch manifest safe-buffer@~5.1.1
292 silly fetch manifest util-deprecate@~1.0.1
293 http fetch GET 304 http://registry.npmjs.org/wrappy 1508ms (from cache)
294 http fetch GET 304 http://registry.npmjs.org/isarray 1522ms (from cache)
295 http fetch GET 304 http://registry.npmjs.org/minimatch 1553ms (from cache)
296 http fetch GET 304 http://registry.npmjs.org/util-deprecate 1596ms (from cache)
297 http fetch GET 304 http://registry.npmjs.org/mkdirp 1829ms (from cache)
298 http fetch GET 304 http://registry.npmjs.org/process-nextick-args 1841ms (from cache)
299 http fetch GET 304 http://registry.npmjs.org/safe-buffer 1892ms (from cache)
300 timing idealTree:node_modules/create-react-app/node_modules/tar-pack Completed in 1928ms
301 timing idealTree:node_modules/create-react-app/node_modules/debug Completed in 0ms
302 silly placeDep node_modules/create-react-app mkdirp@ OK for: fstream@1.0.12 want: >=0.5 0
303 timing idealTree:node_modules/create-react-app/node_modules/fstream Completed in 3ms
304 silly placeDep node_modules/create-react-app minimatch@ OK for: fstream-ignore@1.0.5 want: ^3.0.0
305 timing idealTree:node_modules/create-react-app/node_modules/fstream-ignore Completed in 2ms
306 timing idealTree:node_modules/create-react-app/node_modules/minimatch Completed in 0ms
307 timing idealTree:node_modules/create-react-app/node_modules/mkdirp Completed in 0ms
308 silly placeDep node_modules/create-react-app wrappy@1.0.2 OK for: once@1.4.0 want: 1
309 timing idealTree:node_modules/create-react-app/node_modules/once Completed in 2ms
310 timing idealTree:node_modules/create-react-app/node_modules/rimraf Completed in 0ms
311 timing idealTree:node_modules/create-react-app/node_modules/tar Completed in 0ms
312 timing idealTree:node_modules/create-react-app/node_modules/through Completed in 0ms
313 silly placeDep node_modules/create-react-app/node_modules/through2 readable-stream@1.0.34 OK for: through2@0.6.5 want: >=1.0.33-1 <1.1.0-0
314 silly placeDep node_modules/create-react-app xtend@4.0.2 OK for: through2@0.6.5 want: >=4.0.0 <4.1.0-0
315 timing idealTree:node_modules/create-react-app/node_modules/through2 Completed in 8ms
316 timing idealTree:node_modules/create-react-app/node_modules/tmp Completed in 0ms
317 timing idealTree:node_modules/create-react-app/node_modules/uid-number Completed in 0ms
318 timing idealTree:node_modules/create-react-app/node_modules/universalify Completed in 0ms
319 silly placeDep node_modules/create-react-app builtins@1.0.3 OK for: validate-npm-package-name@3.0.0 want: ^1.0.3
320 timing idealTree:node_modules/create-react-app/node_modules/validate-npm-package-name Completed in 3ms
321 timing idealTree:node_modules/create-react-app/node_modules/builtins Completed in 0ms
322 silly placeDep node_modules/create-react-app isexe@2.0.0 OK for: which@2.0.2 want: ^2.0.0
323 timing idealTree:node_modules/create-react-app/node_modules/which Completed in 2ms
324 timing idealTree:node_modules/create-react-app/node_modules/isexe Completed in 0ms
325 timing idealTree:node_modules/create-react-app/node_modules/wrappy Completed in 0ms
326 timing idealTree:node_modules/create-react-app/node_modules/xtend Completed in 0ms
327 silly placeDep node_modules/create-react-app os-tmpdir@1.0.2 OK for: tmp@0.0.33 want: ~1.0.2
328 timing idealTree:node_modules/create-react-app/node_modules/external-editor/node_modules/tmp Completed in 2ms
329 timing idealTree:node_modules/create-react-app/node_modules/os-tmpdir Completed in 0ms
330 timing idealTree:node_modules/create-react-app/node_modules/jsonfile/node_modules/universalify Completed in 0ms
331 silly placeDep node_modules/create-react-app/node_modules/tar-pack isarray@1.0.0 OK for: readable-stream@2.3.7 want: ~1.0.0
332 silly placeDep node_modules/create-react-app process-nextick-args@2.0.1 OK for: readable-stream@2.3.7 want: ~2.0.0
333 silly placeDep node_modules/create-react-app safe-buffer@5.1.2 OK for: readable-stream@2.3.7 want: ~5.1.1
334 silly placeDep node_modules/create-react-app util-deprecate@1.0.2 OK for: readable-stream@2.3.7 want: ~1.0.1
335 timing idealTree:node_modules/create-react-app/node_modules/tar-pack/node_modules/readable-stream Completed in 12ms
336 timing idealTree:node_modules/create-react-app/node_modules/process-nextick-args Completed in 0ms
337 timing idealTree:node_modules/create-react-app/node_modules/safe-buffer Completed in 0ms
338 timing idealTree:node_modules/create-react-app/node_modules/util-deprecate Completed in 0ms
339 timing idealTree:node_modules/create-react-app/node_modules/tar-pack/node_modules/isarray Completed in 0ms
340 timing idealTree:node_modules/create-react-app/node_modules/through2/node_modules/readable-stream Completed in 0ms
341 timing idealTree:buildDeps Completed in 79656ms
342 timing idealTree:fixDepFlags Completed in 5ms
343 timing idealTree Completed in 79674ms
344 timing command:install Completed in 79679ms
345 verbose type invalid-json
346 verbose stack FetchError: invalid json response body at http://registry.npmjs.org/ansi-escapes reason: Unexpected end of JSON input
346 verbose stack     at /usr/share/npm/node_modules/minipass-fetch/lib/body.js:77:31
346 verbose stack     at async Promise.all (index 12)
346 verbose stack     at async Arborist.[buildDepStep] (/usr/share/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:785:5)
346 verbose stack     at async Arborist.buildIdealTree (/usr/share/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:202:7)
346 verbose stack     at async Arborist.reify (/usr/share/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:121:5)
346 verbose stack     at async install (/usr/share/npm/lib/install.js:40:5)
347 verbose cwd /home/freduah
348 verbose Linux 5.5.0-kali2-amd64
349 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "create-react-app"
350 verbose node v12.19.0
351 verbose npm  v7.0.3
352 error code FETCH_ERROR
353 error errno FETCH_ERROR
354 error invalid json response body at http://registry.npmjs.org/ansi-escapes reason: Unexpected end of JSON input
355 verbose exit 1

【问题讨论】:

你能提供一份打印出来的日志吗?更新你的 npm 版本可能是一个简单的修复。 你是这个意思吗?? /home/freduah/.npm/_logs/2020-10-31T19_11_20_727Z-debug.log 尝试运行npm cache clean --force,然后运行npm i 卸载 create-react-app 包及其任何依赖项,然后尝试重新安装以按照这些instructions进行重新安装 @FreduahGideon 即使我面临同样的问题,尝试了几乎所有网络上的解决方案,如清除缓存、重新安装不同版本的节点等,但仍然没有帮助。你是如何解决的 【参考方案1】:

有时问题是他们尝试使用网络带宽的原因

npm 缓存清理 --force

【讨论】:

我现在必须多次返回这个答案。我想知道为什么这个特定的行没有包含在创建反应应用程序的例程中? 可能是因为它禁用了推荐的保护措施... 不是。创建反应应用程序问题,我对角度 CLI 有同样的问题。所以这可能是一个 npm 问题。 很遗憾为什么 *** 会删除指向 github 的答案解决方案链接。我的意思是为什么?【参考方案2】:

你可以这样做:

npm cache clean --force

其实在最新的版本中,你不需要清楚,你可以:

npm cache verify

【讨论】:

无法编辑帖子,但它是:npm cache verify --verify 不是命令选项。 @JeffreysWorldtravelVids 哦,是的,谢谢【参考方案3】:

我今天也遇到了同样的问题,解决方法是使用 npm install --global --force create-react-app 强制重新安装 create-react-app(如果您喜欢它的简写版本,请输入 npm i -g -f create-react-app)。

如果简单地使用 npm cache verify 验证缓存或使用 npm cache clean --force 强制清理缓存对您不起作用,请尝试卸载并重新安装 create-react-app npm 模块,我希望它可以再次工作!

【讨论】:

【参考方案4】:

由于一些奇怪的原因,这些答案都没有帮助我。我发现这是我的代理的问题。我按照以下步骤解决了它:

npm 缓存清理 --force

npm config rm 代理

npm config rm https-proxy

npm 缓存验证

删除node_modules文件夹并运行

npm 安装

【讨论】:

【参考方案5】:

试试npm cache clean --force

如果不只是重新启动你的电脑。

【讨论】:

【参考方案6】:

这对我有用

    sudo su 登录,而不仅仅是使用sudo 卸载create-react-app:npm uninstall -g create-react-app 强制清洁捕获:npm cache clean --force SWITCH TO OTHER INTERNET ACCESS(我使用的是家庭wifi,但它不起作用,我不知道为什么。可能太慢或ISP的服务器缓存损坏。然后我切换到移动数据)。 (在看到@mydis 在这个NPM Install Error:Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0' 的评论后,我有了这个想法。 重新安装create-react-app:npm i -g create-react-app 再次强制清空:npm cache clean --force 再次尝试创建 react-app:create-react-app my-app

npm 版本 7.5.2 节点版本 12.22.5 反应版本 17.0.2 Debian 11 靶心

我被阻止了几天试图解决这个问题。

【讨论】:

【参考方案7】:

如果项目中缺少 package-lock.json 可能会发生这种情况

【讨论】:

【参考方案8】:

当您遇到代理相关问题时会发生这种情况。我按照以下步骤解决了它:

npm cache clean --force

npm config rm proxy

npm config rm https-proxy

npm cache verify

删除 node_modules 文件夹(如果使用现有包,然后在命令下方运行,否则只需在 CLI 中的命令下方运行)

npm set registry=https://registry.npmjs.org/

然后再次尝试安装新软件包或仅安装 node_modules,如果它给您同样的错误,那么我建议您重新启动笔记本电脑并再次运行上述命令

【讨论】:

以上是关于npm 错误! http://registry.npmjs.org/ansi-escapes 处的无效 json 响应正文 原因:JSON 输入意外结束的主要内容,如果未能解决你的问题,请参考以下文章

npm 错误!代码 ENOENT,npm 错误!错误号 34

npm 错误 npm 错误!代码 ETARGET npm 错误! notarget 没有为 express@undefined4.16.3 找到匹配的版本

npm 错误!错误:尝试更新 npm 时连接 ECONNREFUSED

npm 包无法安装“npm ERR!错误:EACCES:权限被拒绝”

ubuntu 上的 npm 致命错误,知道吗?

升级 npm,npm ERR!错误:EACCES:权限被拒绝