package.json中的根目录 [英] Root directory in package.json
问题描述
我的问题涉及我希望作为NPM模块发布的现有库。该库已被使用,目前需要
d通过本地文件系统。
My question concerns an existing library that I wish to publish as an NPM module. The library is already in use, and currently require
d via the local file system.
怎么能我指定模块文件的根目录?
如果我的结构如下:
.
├── package.json
├── src
| ├── js
| └────── lib
| └───────── my
| └───────────── thing.js
| └───────────── that.js
如何我指定我的模块的根目录和可访问的文件是 src / js / lib / my /
?
How do I specify that the root of my module, and accessible files is src/js/lib/my/
?
我想从外部项目中使用如下:
I would like to use as follows from an outside project:
var thing = require('my/thing'),
that = require('my/that');
我看到files
属性package.json,这是正确的方法吗?
I saw the "files"
property in package.json, is this the right way to go?
推荐答案
对于本机解决方案,请参阅此节点问题 https://github.com/nodejs/node/issues/14970
For a native solution, see this node issue https://github.com/nodejs/node/issues/14970
功能请求在main旁边的package.json中建议 mainDir
字段。
The feature request suggests a mainDir
field in the package.json next to main.
投票的人越多,实施的速度越快/越有可能
The more people that vote, the faster/more likely it will be implemented
这篇关于package.json中的根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!