上周我在NPM上发布了一个非常简单的包。它只包含三个文件:
package.json README.md tofjs-full.node.js
tofjs-full.node.js
包含整个代码,该程序包名为tofjs-full
,在require('tofjs-full')
调用后应该可用。
package.json
文件包含以下内容:
{ "name": "tofjs-full",
"version": "1.0.0",
"description": "`tofjs-full` is the current state of the [TofJs](http://tofjs.org) program, bundled in a single NPM package.",
"author": "bucephalus <bucephalus.org@gmail.com> (http://bucephalus.org)",
"license": "ISC",
"homepage": "http://tofjs.org/program/tofjs-full",
"bugs": { "url": "https://groups.google.com/forum/#!forum/tofjs" },
"repository": "http://tofjs.org/package/tofjs-full/1.0.0/",
"main": "tofjs-full.node.js",
"dependencies": {
"fs-extra": "^0.30.0",
"markdown": "^0.5.0",
"sha1": "^1.1.1",
"sha1-file": "^1.0.0",
"coffee-script": "^1.10.0",
"escodegen": "^1.8.0",
"esprima": "^2.7.2"
},
"files": [ "tofjs-full.node.js" ] }
我通过转到相应目录发布了该包并致电
npm publish
我不记得确切的反应。但是现在可以从NPM存储库(https://www.npmjs.com/package/tofjs-full)正式获得包tofjs-full
。
但是,当我去另一台机器试试
sudo npm install tofjs-full
答案是显示所有依赖关系的树,然后显示一些警告(每行以npm WARN
开头):
ENOENT: no such file or directory, open `'/path/to/dir/package.json'
No description field.
No README data.
No license field.
你能告诉我出了什么问题吗? 谢谢,Bucephalus
答案 0 :(得分:1)
这只是一个警告,因为它无法为您的项目找到package.json,因为我假设像我一样,您刚进入目录并运行onChange: (value: string) => void;
。可以安全地忽略它。
npm install tofjs-full
您应该会发现该库已安装在npm install tofjs-full
- rxjs@5.0.0-beta.6 node_modules/node_modules/node_modules/rxjs
- zone.js@0.6.12 node_modules/node_modules/node_modules/zone.js
/path/dir
├── UNMET PEER DEPENDENCY @angular/core@2.0.0-rc.3
└─┬ tofjs-full@1.0.0
├── coffee-script@1.12.2
├─┬ escodegen@1.8.1
│ ├── estraverse@1.9.3
│ ├── esutils@2.0.2
│ ├─┬ optionator@0.8.2
│ │ ├── deep-is@0.1.3
│ │ ├── fast-levenshtein@2.0.6
│ │ ├── levn@0.3.0
│ │ ├── prelude-ls@1.1.2
│ │ ├── type-check@0.3.2
│ │ └── wordwrap@1.0.0
│ └─┬ source-map@0.2.0
│ └── amdefine@1.0.1
├── esprima@2.7.3
├─┬ fs-extra@0.30.0
│ ├── graceful-fs@4.1.11
│ ├── jsonfile@2.4.0
│ ├── klaw@1.3.1
│ ├── path-is-absolute@1.0.1
│ └─┬ rimraf@2.5.4
│ └─┬ glob@7.1.1
│ ├── fs.realpath@1.0.0
│ ├─┬ inflight@1.0.6
│ │ └── wrappy@1.0.2
│ ├── inherits@2.0.3
│ ├─┬ minimatch@3.0.3
│ │ └─┬ brace-expansion@1.1.6
│ │ ├── balanced-match@0.4.2
│ │ └── concat-map@0.0.1
│ └── once@1.4.0
├─┬ markdown@0.5.0
│ └─┬ nopt@2.1.2
│ └── abbrev@1.0.9
├─┬ sha1@1.1.1
│ ├── charenc@0.0.2
│ └── crypt@0.0.2
└── sha1-file@1.0.0
npm WARN enoent ENOENT: no such file or directory, open '/path/dir/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/path/dir/node_modules/node_modules/package.json'
npm WARN @angular/common@2.0.0-rc.3 requires a peer of @angular/core@2.0.0-rc.3 but none was installed.
npm WARN xxxx No description
npm WARN xxxx No repository field.
npm WARN xxxx No README data
npm WARN xxxx No license field.
答案 1 :(得分:0)
我发布了一个包含三个文件的包,但其中一个文件是原始文件的软链接。似乎npm publish
忽略了软链接,因为后续的npm install
不知道该文件。我通过另一个补丁解决了这个问题,我用适当的文件替换了软链接。
谢谢Kody和baao,你真的帮了我一天! : - )