Difference of using own module and libraries, Nodejs

Asked

Viewed 175 times

1

I’m starting in nodejs, it’s all "new" and I’ve come across this conflict.

There are the modules (I call modules, I don’t know if it’s right) ready etc.. however I have libraries like Cryptojs which has modules for Nodejs and has its library in Javascript for web..

Which is more advantageous to use? The module or just shove the file inside the project and use, edit, perfect etc..

and after all, what’s the difference?

1 answer

0

Module’s are libraries for Node.js. See the excerpt below the Node.js api:

Node has a simple module loading system. In Node, files and modules are in a one-to-one correspondence.

Example of modules:

  • Circle.js
  • Rectangle.js
  • Square js.

A package is one or more modules (libraries) grouped (or packaged) together. These are commonly used by other Packages or in a project of their own. Node.js uses one package manager, where you can find and install thousands of Packages.

Package example:

Shapes             <- Nome do projeto/package
  - Circle.js      <- 
  - Rectangle.js   <- Modulos que pertencem ao package Shapes
  - Square.js      <-

Essentially, you can install the package, Shapes, and have access to the modules Circle.js, Rectangle.js, Square.js.

  • I was confused, what does Packages have to do with the question? Would they be libraries? An?

  • 1

    Basically yes, Packages are module sets in Node.js. For example, express. It is a package that contains several js modules.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.