Answer the question
In order to leave comments, you need to log in
How does npm work?
As far as I understand, npm is such a thing that allows me not to add many references ( <script src="...>, <link rel="...>
) to the tag <head>
. I just add the dependencies to the .json file and they get downloaded somehow. The question is "how"?
You need to create an index.js file that will load dependencies (for example var require('./logger');
). But how to make it load something if you can't put links in the head (including index.js)? Please provide an example of interaction between a .json file and index.js. What should I do with my custom.css? Create a separate module like https://www.npmjs.com/package/bootstrap ? But there are 10 lines of code. Why node_modules, with my jquery.js and bootstrap.js, can't be pushed to GitHub?
Answer the question
In order to leave comments, you need to log in
You have three things mixed up.
1) npm - package manager, manages dependencies, allows you to conveniently download the necessary libraries to the project; 2) module loader, allows you to spread the code into different modules and connect libraries installed using npm (browserify, require.js, systemjs);
3) task runner (grunt/gulp) that allows you to solve related tasks such as gluing scripts for production, compiling less/stylus/sass, etc.
For understanding, you can google some bootstrap gulp boilerplate and see what is done.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question