如何通过运行npm install解决JSON错误?

时间:2019-09-19 17:01:20

标签: node.js

在项目中运行npm install来安装依赖项时,我收到JSON错误。

npm ERR! Unexpected end of JSON input while parsing near '...EsfB30RyD1HUtFKPTfwVO'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/yogesh/.npm/_logs/2019-09-19T16_54_23_816Z-debug.log

我曾尝试清除缓存,但没有任何反应。

npm cache clean --force

还可以重新安装nodejs和所有东西,但没有解决。

这是我的package.json

{
  "name": "project",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~8.2.7",
    "@angular/common": "~8.2.7",
    "@angular/compiler": "~8.2.7",
    "@angular/core": "~8.2.7",
    "@angular/forms": "~8.2.7",
    "@angular/platform-browser": "~8.2.7",
    "@angular/platform-browser-dynamic": "~8.2.7",
    "@angular/router": "~8.2.7",
    "rxjs": "~6.4.0",
    "tslib": "^1.10.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.803.5",
    "@angular/cli": "~8.3.5",
    "@angular/compiler-cli": "~8.2.7",
    "@angular/language-service": "~8.2.7",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^5.0.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.5.3"
  }
}

我该如何解决?

2 个答案:

答案 0 :(得分:1)

只需卸载并重新安装angular cli。清除npm的缓存后

npm cache clean --force

npm uninstall @angular/cli
npm install @angular/cli

这将解决您的问题。

答案 1 :(得分:0)

如果使用的是Vuejs,则要安装最新的nodejs软件包。

您在终端中运行的命令-

curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.35.3/install.sh -o install_nvm.sh

nano install_nvm.sh

bash install_nvm.sh

nvm ls-remote

nvm install 最新版本

nvm use 最新版本

node -v

这将解决您的问题。