Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install showing up to date instead of installing the packages

I am having some trouble with npm install.

npm install package-name is working perfectly, but when I add a new dependency in the package.json file manually (by pulling via git) and then try to npm install only, it returns

up to date in 4.2 sec 

And doesn't install the package.

FYI: I am using git to pull the package.json file. So there is no any issue in the package name. It just doesn't work when i pull and try to install it with npm install only.

My package.json is:

{
  "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"
  }
}
like image 871
Aslam Avatar asked Jun 12 '17 07:06

Aslam


2 Answers

As @j7an said, the problem must depend on the environment. I had the same problem and I didn't know how my NODE_ENV was set to production. Anyway, I did this: (as explained in this answer )

  1. Remove package-lock.json
  2. Remove node_modules

After that:

npm install
npm install --only=dev

This must solve the problem.

like image 85
pouria Avatar answered Sep 29 '22 16:09

pouria


I experienced this issue when I ran export NODE_ENV=production based on the book "Modern JavaScript". After deleting node_modules, package.json, and also clearing npm cache didn't fix the issue, I found the answer from this stackoverflow entry: npm install won't install devDependencies

To fix the issue, I ran export NODE_ENV= which removed the production flag. Once I did that I was able to install dev dependencies again. Hope this helps.

like image 39
j7an Avatar answered Sep 29 '22 17:09

j7an