What is the difference between:
npm install webpack -g
and
npm install -S webpack
What does the big S letter represent? Is it enough if I just install the webpack globally (first statement) or do I have to do the second line of code as well for my project? I couldn't find any clarification on Google for this. I'm familiar with the webpack concept.
-g
stands for "global", which means that particular package not will be saved inside "node_modules" folder in actual working directory. Rather than that, it will be saved in your computer's central package repository, which is usually used by command-line npm application packages (like webpack
).
-S
(big "s") stands for "save", which install the package and saves metadata about it into project's package.json
file. Later on, this file can be shipped with your source code via GIT repository to someone's else development environment. Then, dependency set can be "restored" by invoking npm install
command.
Question for difference between those two actually makes sense. Many developers recommend to use locally (project-scoped) webpack rather than global version - one of main reasons is to make project independent from global webpack and its version, which may vary from user to user and always ship the code with particular webpack version saved in package.json
.