在创建新的Angular项目时,我的Mac终端出现错误。
我在终端写信
ng new ProjectName
我遇到的错误
npm WARN deprecated istanbul-lib-hook@1.2.1: 1.2.0 should have been a major version bump
npm ERR! Unexpected end of JSON input while parsing near '...:"1.1.x","ncname":"1.'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/user/.npm/_logs/2018-08-29T03_03_13_191Z-debug.log
Package install failed, see above.
运行cli命令后获得的完整代码
CREATE crud/README.md (1021 bytes)
CREATE crud/angular.json (3530 bytes)
CREATE crud/package.json (1308 bytes)
CREATE crud/tsconfig.json (384 bytes)
CREATE crud/tslint.json (2805 bytes)
CREATE crud/.editorconfig (245 bytes)
CREATE crud/.gitignore (503 bytes)
CREATE crud/src/environments/environment.prod.ts (51 bytes)
CREATE crud/src/environments/environment.ts (631 bytes)
CREATE crud/src/favicon.ico (5430 bytes)
CREATE crud/src/index.html (291 bytes)
CREATE crud/src/main.ts (370 bytes)
CREATE crud/src/polyfills.ts (3194 bytes)
CREATE crud/src/test.ts (642 bytes)
CREATE crud/src/assets/.gitkeep (0 bytes)
CREATE crud/src/styles.css (80 bytes)
CREATE crud/src/browserslist (375 bytes)
CREATE crud/src/karma.conf.js (964 bytes)
CREATE crud/src/tsconfig.app.json (194 bytes)
CREATE crud/src/tsconfig.spec.json (282 bytes)
CREATE crud/src/tslint.json (314 bytes)
CREATE crud/src/app/app.module.ts (314 bytes)
CREATE crud/src/app/app.component.css (0 bytes)
CREATE crud/src/app/app.component.html (1141 bytes)
CREATE crud/src/app/app.component.spec.ts (987 bytes)
CREATE crud/src/app/app.component.ts (207 bytes)
CREATE crud/e2e/protractor.conf.js (752 bytes)
CREATE crud/e2e/src/app.e2e-spec.ts (300 bytes)
CREATE crud/e2e/src/app.po.ts (208 bytes)
CREATE crud/e2e/tsconfig.e2e.json (213 bytes)
npm WARN deprecated istanbul-lib-hook@1.2.1: 1.2.0 should have been a major version bump
npm ERR! Unexpected end of JSON input while parsing near '...:"1.1.x","ncname":"1.'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/user/.npm/_logs/2018-08-29T03_03_13_191Z-debug.log
Package install failed, see above.
答案 0 :(得分:0)
执行以下操作
应该在清除npm缓存后解决。
npm cache clean --force.