I am studying React.js., and I have started by setting the project folders to try some codes. But, some terms are confusing me as a beginner. One of them is "dependency." When I search for it, the result is only related to dependency injection stuff, but what is the "dependency" itself?
-
From the [`java` tag description](https://stackoverflow.com/tags/java/info): "*Java (**not to be confused with JavaScript or JScript or JS**) ...*". From the [`javascript` tag description](https://stackoverflow.com/tags/javascript/info): "*JavaScript (**not to be confused with Java**) ...*" – Turing85 Aug 15 '20 at 07:23
-
Does this answer your question? [What is dependency in package.json - nodejs](https://stackoverflow.com/questions/10620583/what-is-dependency-in-package-json-nodejs) – jonrsharpe Aug 15 '20 at 07:34
3 Answers
A dependency is some third-party code that your application depends on. Just like a child depends on its parent, your application depends on other people's code. A piece of code becomes a true dependency when your own application cannot function without it.
If you want to look at the dependencies you're using, you can find them in the package.json file under the dependencies key.
- 95
- 1
- 7
-
does it mean that if I have a spring boot project and connect it to angular js, angular js - dependency? – Kloody Mar 03 '22 at 10:59
Well, dependencies are those things that you need to install and import for doing specific things, for example, if you want to add routing(moving from one page to another which changes your URL) in your react project then you need to install react-router-dom dependency by doing
npm install react-router-dom
- 89
- 7
-
Ok, so what is the difference between package and dependency? Don't we get all needed dependencies by installing only packages? – Dawit Mesfin Aug 15 '20 at 07:31
-
-
A dependency is just a package that your project uses.
Very few javascript projects are entirely self-contained. When your project needs code from other projects in order to do its thing, those other projects are "dependencies"; your project depends on them to run.
When you install third-party packages via npm install <package>, you're adding a dependency.
Your project's package.json file includes a list of your project's dependencies.
- 21,681
- 4
- 26
- 25