Though, I have been using NPM, but I do not understand how the files in the node_modules are added to my index.html and work from there.
For Example, if I have to use jQuery, its so simple. I will get the file through cdn and add in my index.html file
CASE I: CDN
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
<script>
$(document).ready(function(){
$('body').css('background','red');
});
</script>
</body>
</html>
Now, I am adding not by cdns, but I will now include jQuery by NPM. I will create a package.json file and then add jQuery by going to the respective folder and type:
CASE II: NPM - node_module folder
I have now done the followign steps:
-
Created package.json by
npm init --yes -
Included jQuery by
npm install jquery --save
Now, by folder looks like this: 
Now, as I have now removed cdn link of jQuery, I dont know how will 'jQuery file' from node_modules will be added to my index.html?
Please, someone help. I have no clue ...
via Deadpool
No comments:
Post a Comment