【问题标题】:Angular: Error while create new project (Unexpected end of JSON input while parsing near)Angular:创建新项目时出错(在附近解析时 JSON 输入意外结束)
【发布时间】:2020-07-31 08:27:24
【问题描述】:

Angular CLI:10.0.4
节点:12.18.3
npm:6.14.6

每次我尝试创建新的角度项目时都会出现错误。 它将挂起(正在安装包...)然后出现错误 在日志文件的一些行下面。 另外,我试过了:

sudo npm cache clean --force

它没有帮助。

请帮忙

2621 silly fetchPackageMetaData error for @angular/compiler@~10.0.5 Unexpected end of JSON input while parsing near '...{"integrity":"sha512-'
2622 silly fetchPackageMetaData error for @angular/platform-browser-dynamic@~10.0.5 Unexpected end of JSON input while parsing near '...":{"integrity":"sha51'
2623 silly pacote range manifest for zone.js@~0.10.3 fetched in 9ms
2624 silly resolveWithNewModule zone.js@0.10.3 checking installable status
2625 timing stage:rollbackFailedOptional Completed in 0ms
2626 timing stage:runTopLevelLifecycles Completed in 48427ms
2627 silly saveTree newproject@0.0.0
2627 silly saveTree ├─┬ @angular/animations@10.0.7
2627 silly saveTree │ └── tslib@2.0.0
2627 silly saveTree ├── @angular/common@10.0.7
2627 silly saveTree ├── @angular/core@10.0.7
2627 silly saveTree ├── @angular/forms@10.0.7
2627 silly saveTree ├── @angular/platform-browser@10.0.7
2627 silly saveTree ├── @angular/router@10.0.7
2627 silly saveTree ├── rxjs@6.5.5
2627 silly saveTree ├── tslib@2.0.0
2627 silly saveTree └── zone.js@0.10.3
2628 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...{"integrity":"sha512-'
2628 verbose stack     at JSON.parse (<anonymous>)
2628 verbose stack     at parseJson (/usr/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)
2628 verbose stack     at /usr/lib/node_modules/npm/node_modules/node-fetch-npm/src/body.js:96:50
2628 verbose stack     at runMicrotasks (<anonymous>)
2628 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:97:5)
2629 verbose cwd /home/eve/Desktop/Practice_programming/angular/newproject
2630 verbose Linux 4.18.0-25-generic
2631 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "--quiet"
2632 verbose node v12.18.3
2633 verbose npm  v6.14.6
2634 error Unexpected end of JSON input while parsing near '...{"integrity":"sha512-'
2635 verbose exit [ 1, true ]

【问题讨论】:

    标签: javascript node.js angular npm


    【解决方案1】:

    尝试更新你的 node js 版本, 尝试清理你的 npm 缓存:npm cache clean --force, 另外,尝试更新您的 Angular CLI 版本npm install npm@latest -g

    【讨论】:

    • 我按照您的建议尝试了,现在错误更改为 npm ERR!在“...”依赖项附近解析时 JSON 输入意外结束:{“fsev”
    • 你试过这个命令 npm i @angular-devkit/build-angular 吗?
    • 在命令 npm i @angular-devkit/build-angular 之后安装了一些包。然后我尝试创建新项目并收到此错误:npm ERR!在 '...0.7.3":{"name":"ts-no' 附近解析时 JSON 输入意外结束
    • 所以请在管理模式下尝试 npm cache clean --force ,如果您使用的是 windows 请删除此文件 C:\Users{{your-username}}\AppData\Roaming\npm-cache 然后npm cache verify 然后 npm i npm@latest -g 然后 npm install angular/cli@latest -g 它应该可以工作并重新启动您的计算机,每一步都应该处于管理员模式。祝你好运
    • 它有效。我尝试了很多事情,例如更改不同版本的节点和 npm 和 angular 和 npm i @angular-devkit/build-angular。不确定哪个有用,但项目是在重新启动笔记本电脑后创建的
    猜你喜欢
    • 1970-01-01
    • 2020-05-24
    • 2021-01-04
    • 2020-11-01
    • 2019-08-04
    • 1970-01-01
    • 1970-01-01
    • 2020-08-15
    • 2019-12-11
    相关资源
    最近更新 更多