Root directory in package.json

前端 未结 7 1631
臣服心动
臣服心动 2020-12-25 10:25

My question concerns an existing library that I wish to publish as an NPM module. The library is already in use, and currently required via the local file syste

相关标签:
7条回答
  • 2020-12-25 11:31

    As the doc says:

    The main field is a module ID that is the primary entry point to your program.

    So you'll have something like "main": "src/js/lib/my/app.js" in your package.json file.

    I would suggest you to create an app.js file and module.exports your different children. For example:

     module.exports.thing = require('./thing');
     module.exports.that = require('./that');
    

    And use them like this:

    var mylib = require('mylib')
      , thing = mylib.thing
      , that = mylib.that;
    
    0 讨论(0)
提交回复
热议问题