admin管理员组

文章数量:1291090

When I try to publish a module in npm repository it is not taking lib folder. I added it in package.json file as below but it is not taking that lib folder. Lib folder contains files that are used by module.

{
    "name": "sample",
    "version": "1.0.0",
    "description": "",
    "main": "sample.js",
    "directories":{
        "lib": "/lib"
    } 
}

When I try to publish a module in npm repository it is not taking lib folder. I added it in package.json file as below but it is not taking that lib folder. Lib folder contains files that are used by module.

{
    "name": "sample",
    "version": "1.0.0",
    "description": "",
    "main": "sample.js",
    "directories":{
        "lib": "/lib"
    } 
}
Share Improve this question edited Jul 10, 2019 at 8:37 Naxos84 2,0381 gold badge24 silver badges35 bronze badges asked Sep 12, 2015 at 10:21 scionoftechscionoftech 6182 gold badges9 silver badges24 bronze badges 1
  • 1 try removing the / from lib so it bees "lib": "lib" – Alex Commented Sep 12, 2015 at 10:38
Add a ment  | 

3 Answers 3

Reset to default 4

remove the / from lib, so your package.json bees

{
    "name": "sample",
    "version": "1.0.0",
    "description": "",
    "main": "sample.js",
    "directories":{
        "lib": "lib"
    } 
}

Add the files to package.json

{
  "files": [ "lib" ]
}

For files or directories ensure the path or paths are specified as expected. Rather than /lib you probably want ./lib. Verify the files and folders you want to publish are not being ignored by a .npmignore or .gitignore dotfile in the lib directory of your project. Also, if there's a separate package.json file in lib you'll wan to check that too.

For more information see:

https://docs.npmjs./files/package.json#files https://docs.npmjs./files/package.json#directories

本文标签: javascripthow to add directory in packagejson to publish in npmStack Overflow