Welcome to the Linux Foundation Forum!

Chapter 6: Packages & Dependencies / Development Dependencies

Quote: "Running npm install without any flags will automatically save the dependency to the package.json file's "dependencies" field."

Could someone clarify what this statement implies? The the previous section implies that the 'npm install' command fetches and installs all the packages listed under the dependencies field in the package.json file into the node_modules directory.

Another point of confusion for me is the statement regarding development dependencies:

Quote:

"An important characteristic of development dependencies is that only top level development dependencies are installed. The development dependencies of sub-dependencies will not be installed"

Could someone elaborate on what the term 'top level' development dependencies refers to?

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Answers

  • Posts: 160

    @itaid when you install a new module that wasn't previous installed it's namespace and version is automatically added to the package.json on your behalf unless you use the --no-save flag

    Re top-level - dependencies can have dependencies and those dependencies can also have dependencies and so forth - so it's a tree. The top level is your project that you're installing modules into. All it means is that if you have a development dependency, and that dev dep has it's own development dependency then the 2nd+ level dev dep will not be installed

  • Posts: 11

    I'm confused because the term 'namespace' isn't defined in this chapter, and my understanding is that a module exports 'identifiers' which are then used by the importing module. I'm aware of the * syntax, which groups all imported identifiers as properties of a named object (similar to a namespace), but I don't see how this relates to npm install. Specifically, the course mentions: 'Running npm install without any flags automatically adds the dependency to the "dependencies" field in the package.json file.' Could you clarify what this means?

  • Posts: 160

    @itaid I just mean name. the name of the module, it's based on the name of the dir when doing npm init -y

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training