E
E
eugene1592021-06-13 03:10:22
npm
eugene159, 2021-06-13 03:10:22

How to use npm correctly?

The project has gulp to build (concatenate and minify) css and js. He uses his libraries.
The site uses other libraries.

The hosting should not have any libraries that gulp uses, since I'm not going to build anything through gulp on the hosting.

When you run the npm install command, both the first and second libraries are placed in the same folder - node_modules.

Do I understand correctly that, in a good way, after installing, for example, the owl-carousel library via npm, I need to go into the node_modules folder, pull out the owl-carousel folder from there and put it somewhere else? And then, when I upload everything to the hosting, I don’t need to upload node_modules, but I only need a folder with libraries for the site, where did I put owl-carousel?

Or maybe the libraries for the site have dependencies? And if so, then you need to somehow determine what exactly these dependencies are, in which folders they are located. And also pull them out of node_modules.

Somehow too much manual work is obtained. It seems to me that this is not the right way to use npm. What is the correct one then?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Neverov, 2021-06-13
@eugene159

There is such a thing as devDependencies .
And there you put the modules that you need for development. In a normal dependency, you put modules that are needed anyway for the application to work.
In general, the correct approach would be to collect all dependencies in 1 bundle and not drag a million modules with you. This is also possible through Gulp, but Webpack is much more convenient in this regard .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question