当我尝试使用
创建新的角度应用程序时出现此错误ng new frontend
这是我得到的错误
npm ERR! Unexpected end of JSON input while parsing near '...dSize":36422127},"eng'
所以我提到了npm git问题,但是找不到解决方案,他们建议这可能是网络问题,并且有人建议重新安装或更新nodejs,npm和angular cli。我确实通过重新安装所有必需的软件来更新所有内容,但是当我尝试运行以下命令时-
npm install --save-dev @angular/cli@latest
我仍然遇到相同的错误。请建议我需要做些什么来创建一个角度为2+(4,5,6)的新ng应用程序。
更新 根据日志,这是失败的地方-我也在较低版本的节点上尝试过
451 silly fetchPackageMetaData error for typescript@>=2.6.2 <2.10 Unexpected end of JSON input while parsing near '...dSize":36422127},"eng'
452 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...dSize":36422127},"eng'
452 verbose stack at JSON.parse (<anonymous>)
452 verbose stack at parseJson (C:\Users\Ganesh\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-better-errors\index.js:7:17)
452 verbose stack at consumeBody.call.then.buffer (C:\Users\Ganesh\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\src\body.js:96:50)
452 verbose stack at <anonymous>
452 verbose stack at process._tickCallback (internal/process/next_tick.js:188:7)
453 verbose cwd D:\
454 verbose Windows_NT 10.0.17134
455 verbose argv "D:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Ganesh\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "@angular/cli"
456 verbose node v8.9.4
457 verbose npm v5.6.0
更新2 由于我发现安装Typescript时存在错误,因此我尝试使用
直接安装Typescript npm i -g typescript
我发现它正在尝试访问文件
https://registry.npmjs.org/typescript
并且我发现在json中只有一个这样的位置发生错误。这是新的日志:-
0 info it worked if it ends with ok
1 verbose cli [ 'D:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\Ganesh\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'typescript' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose npm-session 51a5c57f485d99fd
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 200 https://registry.npmjs.org/typescript 31ms (from cache)
8 silly fetchPackageMetaData error for typescript@latest Unexpected end of JSON input while parsing near '...dSize":36422127},"eng'
9 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...dSize":36422127},"eng'
9 verbose stack at JSON.parse (<anonymous>)
9 verbose stack at parseJson (C:\Users\Ganesh\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-better-errors\index.js:7:17)
9 verbose stack at consumeBody.call.then.buffer (C:\Users\Ganesh\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\src\body.js:96:50)
9 verbose stack at <anonymous>
9 verbose stack at process._tickCallback (internal/process/next_tick.js:188:7)
10 verbose cwd D:\
11 verbose Windows_NT 10.0.17134
12 verbose argv "D:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Ganesh\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "typescript"
13 verbose node v8.9.4
14 verbose npm v5.6.0
15 error Unexpected end of JSON input while parsing near '...dSize":36422127},"eng'
16 verbose exit [ 1, true ]
但是现在我该怎么办?请帮助我进行下一步。
答案 0 :(得分:0)
我找不到问题的答案,因此尝试在Windows 10中使用新的用户帐户。现在,这对我有所帮助。对于Windows中的此类问题,我仍然感到非常不舒服。