下面是prj文件夹结构
带有package.json的子文件夹与主项目无关, 这些都是第三方库
当我尝试 npmpublish --dry-run 时忽略提到的 src 文件夹
注意:不存在 .npmignore 文件
your-project/
├── src/
│ ├── common/
│ │ └── js/
│ │ └── lib/
│ │ ├── subfolder1/
| | |--------src/ // folders not getting included in npm publish
│ │ │ ├── fileA.js
│ │ │ ├── fileB.js
│ │ │ └── package.json
│ │ ├── subfolder2/
| | |---------src/ // folders not getting included in npm publish
│ │ │ ├── fileC.js
│ │ │ └── package.json
│ │ └── ...
│ └── ...
├── README.md
└── package.json
这是package.json
{
"name": "ui-libraries",
"version": "1.0.0-dev",
"private": false,
"description": "Consolidated UI libraries",
"scripts": {
"build": "echo 'No build necessary'"
},
"author": "",
"license": "ISC",
"files": [
"src/common/js/lib/**/**/*",
"README.md"
]
}
更简单的模式会更有效
"files": [
"src/common/js/lib/**/*",
"README.md"
]
甚至
"files": [
"src/common/js/lib/**",
"README.md"
]
你应该两者都尝试一下。