[英]How do I generate a separate package.json file in the dist directory?
I'm creating a package to publish to npm. 我正在创建一个要发布到npm的程序包。
Please help. 请帮忙。
You should have a single package.json for your project, and it's meant to be published on NPM. 您应该为您的项目创建一个package.json文件,并将其发布在NPM上。 The idea with
devDependencies
is that they won't get installed when people install your package from NPM, as opposed to dependencies
, which do get installed. 有这个想法
devDependencies
是,他们将不会安装,当人们从NPM安装你的包,而不是dependencies
,这做得到安装。
For your package to work as expected, you need at least the main
field that points to your main JS file. 为了使程序包按预期工作,至少需要指向主JS文件的
main
字段。
See the docs for package.json
for a list of available fields. 有关可用字段的列表,请参阅
package.json
的文档 。
You should use package.json
in your directory. 您应该在目录中使用
package.json
。
Publish file you want with files
of package.json
, 使用
package.json
files
发布所需的文件,
choose your main file (file will call by require
) with main
of package.json
选择您的主文件(文件将被调用
require
用) main
的package.json
You should read npm package.json 您应该阅读npm package.json
Example: ( dist
is directory build by gulp
) 示例:(
dist
是由gulp
建立的目录)
{
"name": "<your_module>",
"files": [
"dist",
"someFile.js"
],
"main": "dist/index.js",
...
}
With this way, you should add module build your module
to devDependencies
, module was called by your module
in dependencies
这样,您应该将模块构建
your module
添加到devDependencies
, your module
在dependencies
被模块调用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.