Iam new to cypress wanted to know what is difference between npm install cypress
vs npm install cypress --save-dev
I googled but not finding any answers
CodePudding user response:
With npm install cypress
, you are just installing cypress. with npm install --save-dev
you are installing it as a dev dependency.
CodePudding user response:
The difference between these two, is that devDependencies are modules which are only required during development, while dependencies are modules which are also required at runtime. src
Modules like Mochajs, cypress, jsdoc, etc are devDependencies, because they are useful just in develop Env and in Production Env We don't need them.
There are at least 2 different envs while developing, somewhere you develop and code and do some tests on your code(develop Env) and somewhere you deliver your product to your customer, which means you have tested your code completely and there is no need to run tests again(product).
You need some modules like cypress and mocha just for testing. In product env you don't need to test the product again. So you don't install extra modules!
So you need something like devDependencies
in package manager to handle it for you.
CodePudding user response:
Please refer to the details here
npm dependencies and devDependencies
When you install an npm package using
npm install cypress
, you are installing it as a dependency.When you add the
-D
flag, or--save-dev
, you are installing it as a development dependency, which adds it to thedevDependencies
list.Development dependencies are intended as development-only packages, that are unneeded in production.
When you go in production, if you type npm install and the folder contains a package.json file, they are installed, as npm assumes this is a development deploy.
You need to set the
--production
flag (npm install --production
) to avoid installing those development dependencies.