简体   繁体   English

当项目作为依赖项包含时,节点模块的控制内容

[英]Control content of node module when included as dependency by a project

Let's say I have a node project 'A' with a JS file, 10 resource files and some test files. 假设我有一个节点项目“ A”,其中包含一个JS文件,10个资源文件和一些测试文件。

There is another project 'B' which depends on the JS file of project 'A'. 还有另一个项目“ B”,该项目取决于项目“ A”的JS文件。 So, it includes it as dependency in package.json as: 因此,它将它作为依赖项包含在package.json中,如下所示:

"dependencies": {
    "A": "git+https://github.com/repo/A.git"
}

But this will also try to fetch all unwanted files like resources and test files of project 'A' in node_modules folder. 但这也将尝试在node_modules文件夹中获取所有不需要的文件,例如资源和项目“ A”的测试文件。

Is there a way I can control in package.json of 'A' that which files to expose if included as dependency? 如果包含在依赖项中,有什么办法可以控制我在package.json的'A'中公开哪些文件?

I believe .npmignore is what you need. 我相信.npmignore是您所需要的。 Please see Keeping files out of your package 请参阅将文件移出包装

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何更新本地 node_module 依赖项并在另一个项目中重新加载? - How to update local node_module dependency and reload in another project? 为什么Node不作为Express的依赖项? - Why isn't Node included as a dependency for Express? 从nodejs项目构建rpm包时缺少节点依赖性 - missing node dependency when building an rpm package from nodejs project 当项目中不包含node_modules文件夹时,Node.js在哪里搜索模块? - Where does Node.js search for modules when no node_modules folder included in project? Node.js:使用“ vm”模块运行脚本时,控制“ this”的值吗? - Node.js: control the value of `this` when running a script with the `vm` module? 如何引用节点模块中包含的 nunjucks 模板? - How to reference a nunjucks template included in a node module? Alloy项目中的节点模块 - Node module in Alloy project 尝试在 Heroku 上部署项目时出现节点模块错误? - Node Module Error When Trying To Deploy Project On Heroku? 在java项目中添加node js项目作为依赖 - Add node js project as a dependency in a java project 使用browserify捆绑带有--node标志的socket.io依赖项时出现“错误:无法找到模块” - “Error: Cannot find module” when using browserify to bundle a socket.io dependency with --node flag
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM