call files from the same module

0

Hello a moment ago I saw in a repository that I could call in the same project folder subfolders or files that were declared in package.json by @declaracion: file: nombrearchivo I think I saw it in several more sides but I did not give importance, now I wanted to find how it works but I can not find this in the docs of nodejs or in those of npm then two things one explain to me the operation and two pass me the link of the documentation

    
asked by soldat25 01.07.2018 в 04:27
source

2 answers

0

I found the documentation in npm I almost can not find it here I had never used it in this way but if I knew that you can also upload a repository from github , the explanation is as follows

// package.json
dependencies: {
'@milibreria': 'file:./milibreria'
}
//node
// cuando se require
const milibreria =require('@milibreria')

In my case, note that you should have another file package.json with the name you put in the package.json main and then give npm install

    
answered by 01.07.2018 / 20:04
source
1

The process to install a package of npm is:

  • If you do not have npm started in the project: npm init (the package.json will be created)
  • To install a npm module uploaded to the official npm repo:

    npm install --s nombre-del-modulo (for local installation in the project)

  • The dependency with that module will automatically be written in the package.json, so that when you perform npm install (for example when you clone a project) all existing modules are automatically installed in dependencies of the package.json

  • I hope it serves you, best regards

        
    answered by 05.07.2018 в 01:58