0
Here’s an example of the file package.json
, installed using the command
npm install <nome> --save-dev
:
{
"dependencies": {},
"devDependencies": {
"bootstrap": "^4.1.3",
"cross-env": "^5.2.0",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
"node-sass": "^4.9.3"
}
}
If I just change manually like this, is something wrong? Outside of some convention, or can something else go wrong later?
(disregard the functionality of the packages, are only to exemplify):
{
"dependencies": {
"font-awesome": "^4.7.0",
},
"devDependencies": {
"bootstrap": "^4.1.3",
"cross-env": "^5.2.0",
"jquery": "^3.3.1",
"node-sass": "^4.9.3"
}
}
True, I forgot the comma. But as for your tip to use --save-Prod or --save-dev I had tried earlier and it does not make the change. I had to uninstall the package before and download it all again with the correct option.
– Luiz
Strange, I just tested here with the commands and it worked (it moved the package from one to the other). My
node
is in the version8.10.0
and mynpm
in the version5.6.0
– Fábio Peres Toi
It must be version then, when I did this, Node was in version 5.6 I think. Fabio, can I amend another pertinent question? If my project already has the folder
node_modules
in the.gitignore
, what is the usability of this option--save-dev
? In which case does it make a difference? Thank you.– Luiz
the idea of
--save-dev
is that you (or any other developer working on the project) can install modules needed only for the development phase, on your local machine or IC environment (e.g., test modules, such asava
). These modules will not be installed in your production environment. Having them in package.json allows anyone, when cloning the project, just to runnpm install
to start developing– Fábio Peres Toi
This part I understood. But what prevents me from raising them to production. Nothing correct? It serves only
demonstrador
from what I understand. Who reallyolha
what goes into production andseleciona
is just the.gitignore
in the case of a userGit
, That? Thank you so much for your time.– Luiz