Change package.json file dependency on the basis of production and development

Viewed 411

I want to change my electron version in package.json file on the basis of the production and development stage. If my project in the development phase then it will take electron 11.2.0 version and in production my electron version must be electron 3.1.1. Is there any way to do this task or apply this condition on my package.json file?

1 Answers

Yeah.

You can add a devDependencies object to your package.json. Also when you install packages to your project you can install them with the --save-dev flag to automatically do that.

It will look like this:

"name": "my_package",
"version": "1.0.0",
"dependencies": {
  "my_dep": "^1.0.0",
  "another_dep": "~2.2.0"
},
"devDependencies" : {
  "my_test_framework": "^3.1.0".
  "another_dev_dep": "1.0.0 - 1.2.0"
}

More information can be found in the official documentation for npm.

https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file

Related