我正在尝试在Windows 10设备上使用npm install -g @angular/cli
安装angular-cli。然后显示以下错误。
C:\Users\kumar>npm install -g @angular/cli
npm ERR! Unexpected end of JSON input while parsing near '...Gers\r\n=IoR7\r\n----'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\kumar\AppData\Roaming\npm-cache\_logs\2019-04-16T17_17_28_711Z-debug.log
完整的日志是:
0 info it worked if it ends with ok
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 '-g',
1 verbose cli '@angular/cli' ]
2 info using npm@6.4.1
3 info using node@v10.15.3
4 verbose npm-session 340bac50265b23c5
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 200 https://registry.npmjs.org/@angular%2fcli 41ms (from cache)
8 silly pacote tag manifest for @angular/cli@latest fetched in 95ms
9 timing stage:loadCurrentTree Completed in 573ms
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
13 silly install loadShrinkwrap
14 timing stage:loadIdealTree:loadShrinkwrap Completed in 4ms
15 silly install loadAllDepsIntoIdealTree
16 silly resolveWithNewModule @angular/cli@7.3.8 checking installable status
17 http fetch GET 200 https://registry.npmjs.org/ini 78ms (from cache)
18 http fetch GET 200 https://registry.npmjs.org/@yarnpkg%2flockfile 80ms (from cache)
19 http fetch GET 200 https://registry.npmjs.org/@angular-devkit%2farchitect 93ms (from cache)
20 silly fetchPackageMetaData error for @angular-devkit/architect@0.13.8 Unexpected end of JSON input while parsing near '...Gers\r\n=IoR7\r\n----'
21 http fetch GET 200 https://registry.npmjs.org/open 86ms (from cache)
22 silly pacote version manifest for @yarnpkg/lockfile@1.1.0 fetched in 96ms
23 silly resolveWithNewModule @yarnpkg/lockfile@1.1.0 checking installable status
24 silly pacote version manifest for ini@1.3.5 fetched in 100ms
25 silly resolveWithNewModule ini@1.3.5 checking installable status
26 http fetch GET 200 https://registry.npmjs.org/inquirer 102ms (from cache)
27 http fetch GET 200 https://registry.npmjs.org/npm-package-arg 104ms (from cache)
28 silly pacote version manifest for open@6.0.0 fetched in 112ms
29 silly resolveWithNewModule open@6.0.0 checking installable status
30 http fetch GET 200 https://registry.npmjs.org/@schematics%2fupdate 132ms (from cache)
31 http fetch GET 200 https://registry.npmjs.org/@angular-devkit%2fcore 140ms (from cache)
32 silly pacote version manifest for inquirer@6.2.1 fetched in 134ms
33 silly resolveWithNewModule inquirer@6.2.1 checking installable status
34 silly pacote version manifest for npm-package-arg@6.1.0 fetched in 134ms
35 silly resolveWithNewModule npm-package-arg@6.1.0 checking installable status
36 http fetch GET 200 https://registry.npmjs.org/@schematics%2fangular 147ms (from cache)
37 http fetch GET 200 https://registry.npmjs.org/symbol-observable 42ms (from cache)
38 http fetch GET 200 https://registry.npmjs.org/@angular-devkit%2fschematics 156ms (from cache)
39 http fetch GET 200 https://registry.npmjs.org/semver 52ms (from cache)
40 silly pacote version manifest for @schematics/update@0.13.8 fetched in 163ms
41 silly resolveWithNewModule @schematics/update@0.13.8 checking installable status
42 silly pacote version manifest for @angular-devkit/core@7.3.8 fetched in 167ms
43 silly resolveWithNewModule @angular-devkit/core@7.3.8 checking installable status
44 http fetch GET 200 https://registry.npmjs.org/pacote 73ms (from cache)
45 silly pacote version manifest for @schematics/angular@7.3.8 fetched in 174ms
46 silly resolveWithNewModule @schematics/angular@7.3.8 checking installable status
47 silly pacote version manifest for symbol-observable@1.2.0 fetched in 64ms
48 silly resolveWithNewModule symbol-observable@1.2.0 checking installable status
49 silly pacote version manifest for semver@5.6.0 fetched in 72ms
50 silly resolveWithNewModule semver@5.6.0 checking installable status
51 silly pacote version manifest for pacote@9.4.0 fetched in 88ms
52 silly resolveWithNewModule pacote@9.4.0 checking installable status
53 silly pacote version manifest for @angular-devkit/schematics@7.3.8 fetched in 183ms
54 silly resolveWithNewModule @angular-devkit/schematics@7.3.8 checking installable status
55 timing stage:rollbackFailedOptional Completed in 1ms
56 timing stage:runTopLevelLifecycles Completed in 789ms
57 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...Gers\r\n=IoR7\r\n----'
57 verbose stack at JSON.parse (<anonymous>)
57 verbose stack at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
57 verbose stack at consumeBody.call.then.buffer (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50)
57 verbose stack at process._tickCallback (internal/process/next_tick.js:68:7)
58 verbose cwd C:\Users\kumar
59 verbose Windows_NT 10.0.17134
60 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "@angular/cli"
61 verbose node v10.15.3
62 verbose npm v6.4.1
63 error Unexpected end of JSON input while parsing near '...Gers\r\n=IoR7\r\n----'
64 verbose exit [ 1, true ]
答案 0 :(得分:2)
本地NPM缓存可能有问题。您可以尝试在这里推荐的解决方案mcemmy:https://stackoverflow.com/a/47896884/5997923
答案 1 :(得分:1)
清除您的 package-lock.json 并放置一个空对象npm cache clean
,
做npm install
执行{{1}}。
应该解决的问题