Often I meet on GitHub modules, in the description of which there are something like these: old school Grab file from dist directory

in this case, the priority installation method is the installation using npm, npm install --save cleave.js

To be honest, I don’t want to be "old school", but I don’t understand the logic of the installation of the npm-package, because in fact the entire branch from the hub is downloaded to the .node-modules folder of my project

The essence of the question: how to use the example of https://github.com/nosir/cleave.js to go all the way from npm install --save cleave.js to including the necessary files in html?

    2 answers 2

    You need to issue / create a package for npm .

     npm init 

    He creates the package.json file, you can create it with your own hands, as it is more convenient.

    Learn what options this file contains: https://docs.npmjs.com/files/package.json

    Next, you need to publish your package in the general registry npm , here is the link with the instruction: https://docs.npmjs.com/getting-started/publishing-npm-packages

    In short, first create the user through the console, then publish your package.

    upd: I forgot to write to the github account, in package.json there is a parameter responsible for this, here’s a piece from the manual:

     "repository": { "type" : "git", "url" : "https://github.com/npm/npm.git" } 
    • The fact is that package.json has been created a long time ago, since I use some modules. The problem is that I install this module, which creates its own directory in node_modules, and then I just don’t understand how to configure it (this module) for use in my project. As of the folder created by the module, I pull out the files I need and put in the destination (for example "./js/") I understand - griff92
    • Well, if this module allows such a custom, then it’s logical that you include the package / file from node_modules and use it, but if such a caste is not provided, then as you wrote, either copy to the js folder :) or make a project fork and perepilit what you need, well, or create an issue in the project - maxkrasnov
    • maybe I misunderstood the essence - maxkrasnov
    • interested in the algorithm of actions between these 2 stages: github.com/nosir/cleave.js#installation and github.com/nosir/cleave.js#usage - griff92
    • @ griff92, well, it turns out you need 100% some kind of collector (this is not just a piece of work), otherwise stupidly copying (as you wrote) or directly in src to refer to node_modules that seems to me not good - maxkrasnov

    You can directly depend on the githab project without publishing it in npm:

    package.json

     { ..., "dependencies": { "tiny-sdf": "git+https://github.com/strangerintheq/tiny-sdf.git#1.1.9" } } 

    after the grid is the name of the tag or branch, you can hash commit