簡體   English   中英

當我輸入這個命令“npm install”時不安裝 node_modules

[英]not install node_modules when I type this command "npm install"

當我使用此命令npm install安裝 node_modules 時,出現以下錯誤。 在這種情況下,如何修復此錯誤?

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包。 當我在所有項目中安裝````node modules``` 時會發生此錯誤。

請從package.json相關的 acorn 中刪除"acorn": "^5.7.2",並按照以下步驟操作,

rm -rf node_modules/
npm install

然后通過終端手動安裝橡子

npm install acorn --save

如果它不起作用,那么你可以嘗試

npm install acorn --unsafe-perm --save

希望能幫到你 !!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM