2017-06-12 119 views
3

我在npm安裝時遇到了一些麻煩。npm安裝顯示最新,而不是安裝包

npm install package-name工作完美,但是當我在package.json文件中手動添加一個新的依賴(由通過git的拉動),然後嘗試npm install只,它返回

up to date in 4.2 sec 

而且不安裝包。

僅供參考:我正在使用git來提取package.json文件。所以包名中沒有任何問題。它只是不起作用,當我拉,並嘗試僅與npm install安裝它。

我的package.json是:

{ 
    "name": "ap", 
    "version": "0.0.0", 
    "license": "MIT", 
    "scripts": { 
    "ng": "ng", 
    "start": "ng serve", 
    "build": "ng build", 
    "test": "ng test", 
    "lint": "ng lint", 
    "e2e": "ng e2e" 
    }, 
    "private": true, 
    "dependencies": { 
    "@angular/common": "^4.0.0", 
    "@angular/compiler": "^4.0.0", 
    "@angular/core": "^4.0.0", 
    "@angular/forms": "^4.0.0", 
    "@angular/http": "^4.0.0", 
    "@angular/platform-browser": "^4.0.0", 
    "@angular/platform-browser-dynamic": "^4.0.0", 
    "@angular/platform-server": "^4.1.3", 
    "@angular/router": "^4.0.0", 
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.26", 
    "@ngx-translate/core": "^6.0.1", 
    "@ngx-translate/http-loader": "0.0.3", 
    "@types/underscore": "^1.8.0", 
    "angular-datatables": "^4.1.0", 
    "angular2-busy": "^2.0.4", 
    "angular2-jwt": "^0.2.3", 
    "angular2-toaster": "^4.0.0", 
    "chart.js": "^2.6.0", 
    "core-js": "^2.4.1", 
    "datatables.net": "^1.10.15", 
    "datatables.net-dt": "^1.10.15", 
    "jquery": "^3.2.1", 
    "ng2-charts": "^1.5.0", 
    "ng2-simple-timer": "^1.3.1", 
    "rxjs": "^5.1.0", 
    "underscore": "^1.8.3", 
    "zone.js": "^0.8.4" 
    }, 
    "devDependencies": { 
    "@angular/animations": "^4.1.3", 
    "@angular/cli": "1.0.4", 
    "@angular/compiler-cli": "^4.0.0", 
    "@types/datatables.net": "^1.10.1", 
    "@types/jasmine": "2.5.38", 
    "@types/jquery": "^2.0.45", 
    "@types/node": "~6.0.60", 
    "codelyzer": "~2.0.0", 
    "jasmine-core": "~2.5.2", 
    "jasmine-spec-reporter": "~3.2.0", 
    "karma": "~1.4.1", 
    "karma-chrome-launcher": "~2.1.1", 
    "karma-cli": "~1.0.1", 
    "karma-coverage-istanbul-reporter": "^0.2.0", 
    "karma-jasmine": "~1.1.0", 
    "karma-jasmine-html-reporter": "^0.2.2", 
    "protractor": "~5.1.0", 
    "ts-node": "~2.0.0", 
    "tslint": "~4.5.0", 
    "typescript": "~2.2.0" 
    } 
} 

回答

0

我遇到過這個問題,當我的立足之本 「現代的JavaScript」 跑export NODE_ENV=production。刪除node_modules,的package.json,並清除緩存NPM沒有解決這個問題後,我發現從這個計算器進入了答案:npm install won't install devDependencies

爲了解決這個問題,我跑export NODE_ENV=可以除去生產標誌。一旦我這樣做了,我可以再次安裝開發依賴項。希望這可以幫助。

+0

我會檢查並通知您。 – Aslam

0

正如@ j7an所說,問題必須取決於環境。我有同樣的問題,我不知道我的NODE_ENV如何設置爲生產。無論如何,我這樣做:(在this answer解釋)

  1. 刪除package-lock.json
  2. 刪除node_modules

之後:

npm install 
npm install --only=dev 

這必須解決的問題。