Is npm installed --save-dev gulp-uglify different to npm install gulp-uglify

I am confused about the npm install process. As far as I understand, there are different options for installing modules:

  • -g, which stores modules all over the world.
  • - save-dev
  • no arguments.

Can someone please explain what the differences are? Specifically, when I do a -g (global) and the other installs locally, does it get the modules from where I saved it globally?

And what does it mean: "--save: the package will appear in your dependencies".

What addictions is he talking about?

+3


source to share


2 answers


Good. So here:

  • If you want to install locally locally, run: npm install gulp-uglify

    and create a folder called node_modules where you will find the required module.
  • If you want to install the package globally instead, then you need to run:, npm install -g gulp-uglify

    which will highlight the package in your OS and you can use it anywhere (not just in that folder).
  • The --save-dev option (which will npm install --save-dev gulp-uglify

    ) will also update your package.json file and it will be added as a developer dependency, which is your application manifest. This means that in this file you will declare all the dependencies that you need in your project, and they will be installed only by running npm install

    . Json file you need to run npm init

    .


More information can be found here . Or this other post . Hope this helps!

+4


source


-g puts the module in your global node_modules directory. They are accessible from any directory (hence the global)

- save-dev updates the package.json file to include the module as a developer dependency. They are downloaded to the local node_modules folder for the directory.

No save argument updates the package.json file to include the module as a dependency. They are also downloaded to the local node_modules folder for the directory.



devDependencies and dependencies have consequences when someone wants to install your project (via npm install). For example npm install

will install all dependencies and devDependencies. npm install --production

will not install devDependencies.

Thus, you should use -save-dev when the node module you are importing is used for development purposes and not for execution (like maybe jshint for building). Modules required to run the application should not use the -save-dev switch.

+2


source







All Articles