1
I’m beginning to understand the NPM now, I am very old school and I need to update myself.
I installed via NPM Jquery and some library to test (Inputmask). It seems that everything worked out, the folders were created inside the node_modules folder and my package.json file was like this:
{
"name": "npm_tutorial",
"version": "1.0.0",
"description": "testando a instalacao via npm",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"teste"
],
"author": "caiocafardo",
"license": "ISC",
"devDependencies": {
"jquery": "^3.2.1"
},
"dependencies": {
"inputmask": "^3.3.5"
}
}
Now my question: how to use Jquery and Inputmask in HTML? I’ll have to call it like I always did?
<script type="text/javascript" src="node_modules/jquery/dist/jquery.min.js"></script>
Or is there some way to call more easily (all at once)? This index.js file became empty, it would be he who does the magic?
Are you using webpack, or Browserify? you have a server or are just testing in a static html file?
– Sergio
Locally, a static file. About webpack and Browserify, sorry, but I’m not using either....
– caiocafardo
In that case it works well as it is, assuming that the file
.html
is on the project’s core board. You got it up and running?– Sergio
Yes, in the traditional way using script. But there is no advantage in using NPM. I can very well download the JS and call, right? I wanted to understand the advantage of using NPM.... because if I have to call it equal I always called, I see no advantage
– caiocafardo
Yes, exactly. Using npm is just a practical way to get the file into your project. But CDN is better if you work online, otherwise (offline) you really need the file locally.
– Sergio
But via CDN would use Github?
– caiocafardo
No, it uses Google directories for example: https://developers.google.com/speed/libraries/#jquery
– Sergio