Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"npm install [package]" doesn't update package.json

I've been using Laravel and trying to use angular-ui-sortable and angular-utils-pagination.

I installed them with npm, but can't get package.json updated for angular-utils-pagination.

The file now looks like...

 {
  "private": true,
  "devDependencies": {
   "gulp": "^3.8.8"
  },
  "dependencies": {
    "angular-ui-sortable": "^0.14.0",
    "bootstrap-sass": "^3.0.0",
    "laravel-elixir": "^4.0.0"
  }
}

The point is that angular-ui-sortable is there but angular-utils-pagination is not. Both files are under node_module folder. As far as I understand, those libraries have to be under dependencies in package.json for them to be available.

Any advice will be appreciated.

like image 614
Hiroki Avatar asked Jun 02 '16 22:06

Hiroki


People also ask

Does npm install update package json?

The npm install installs all modules that are listed on package. json file and their dependencies. npm update updates all packages in the node_modules directory and their dependencies.

Does npm install install everything in Package json?

By default, npm install will install all modules listed as dependencies in package.json .


2 Answers

To add a angular-utils-pagination under dependencies try:

npm install angular-utils-pagination --save

It should now appear in the package.json file.

For reference, adding dependencies to package.json:

npm install <package> --save

Adding dev dependencies to package.json:

npm install <package> --save-dev

Good luck!

like image 199
Ann Nguyen Avatar answered Nov 03 '22 00:11

Ann Nguyen


In order to save the package in the package.json file as a dependency you need to write

npm install <package-name> --save 

if you want to save the package as a development package only (not to be installed on production server) write the following:

npm install <package-name> --save-dev

To install dependencies from the package.json file:

npm install *installs all dependencies*
npm install --production *will only install "dependencies"*
npm install --dev *will only install "devDependencies"*
like image 33
Bamieh Avatar answered Nov 03 '22 00:11

Bamieh