当我键入此命令“ npm install”时,未安装node_modules

时间:2019-03-25 09:47:20

标签: node.js npm-install

当我使用此命令安装node_modules时 npm install,我遇到了以下错误。 在这种情况下,如何解决此错误?

npm ERR! errno HPE_INVALID_CONSTANT
npm ERR! request to https://registry.npmjs.org/acorn/-/acorn-5.7.2.tgz failed, reason: Parse Error

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\IR-16\AppData\Roaming\npm-cache\_logs\2019-03-25T10_35_26_869Z-debug.log

我的package.json在下面:

{
  "name": "discover",
  "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": "^6.1.0",
    "@angular/common": "^6.1.0",
    "@angular/compiler": "^6.1.0",
    "@angular/core": "^6.1.0",
    "@angular/forms": "^6.1.0",
    "@angular/http": "^6.1.0",
    "@angular/platform-browser": "^6.1.0",
    "@angular/platform-browser-dynamic": "^6.1.0",
    "@angular/router": "^6.1.0",
    "angular2-useful-swiper": "^5.0.1",
    "bootstrap": "^4.1.3",
    "core-js": "^2.5.4",
    "ng-simple-slideshow": "^1.2.4",
    "ngx-toggle-switch": "^2.0.5",
    "ngx-ui-switch": "^1.6.0",
    "rxjs": "^6.0.0",
    "swiper": "3.4.2",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.7.0",
    "@angular/cli": "~6.1.5",
    "@angular/compiler-cli": "^6.1.0",
    "@angular/language-service": "^6.1.0",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2"
  }
}

如您所见,从未安装acorn软件包。 当我在所有项目中安装``节点模块''时会发生此错误。

1 个答案:

答案 0 :(得分:1)

请从与"acorn": "^5.7.2",相关的橡子中删除package.json,然后执行以下步骤,

rm -rf node_modules/
npm install

然后通过终端手动安装橡子

npm install acorn --save

如果它不起作用,那么您可以尝试

npm install acorn --unsafe-perm --save

希望这对您有帮助!