2017-01-17 66 views
0

上週我發佈了一個非常簡單的NPM軟件包。它僅包括三個文件:`npm publish`然後`npm install`不能恢復已發佈的軟件包

package.json README.md tofjs-full.node.js 

tofjs-full.node.js包含整個代碼時,包被稱爲tofjs-fullrequire('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 <[email protected]> (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 

我不記得確切的反應。但是tofjs-full程序包現在可以從NPM存儲庫(https://www.npmjs.com/package/tofjs-full)正式獲得。

然而,當我去到另一臺機器,並嘗試 須藤NPM安裝tofjs全 答案是所有的依賴關係,然後一些警告的樹顯示(每行開頭npm WARN):

ENOENT: no such file or directory, open `'/path/to/dir/package.json' 
No description field. 
No README data. 
No license field. 

你能告訴我發生了什麼事嗎? 謝謝比塞弗勒斯

+0

...對不起,我的意思是說:「包'tofjs-full'現在可以從NPM存儲庫正式獲得。」而不是「......不正式可用......」。 – user2527816

回答

1

這僅僅是一個警告,因爲它無法找到您的項目的package.json,因爲我認爲像我這樣的,你只是去到一個目錄並運行npm install tofjs-full。它可以安全地忽略。

npm install tofjs-full 
- [email protected] node_modules/node_modules/node_modules/rxjs 
- [email protected] node_modules/node_modules/node_modules/zone.js 
/path/dir 
├── UNMET PEER DEPENDENCY @angular/[email protected] 
└─┬ [email protected] 
    ├── [email protected] 
    ├─┬ [email protected] 
    │ ├── [email protected] 
    │ ├── [email protected] 
    │ ├─┬ [email protected] 
    │ │ ├── [email protected] 
    │ │ ├── [email protected] 
    │ │ ├── [email protected] 
    │ │ ├── [email protected] 
    │ │ ├── [email protected] 
    │ │ └── [email protected] 
    │ └─┬ [email protected] 
    │ └── [email protected] 
    ├── [email protected] 
    ├─┬ [email protected] 
    │ ├── [email protected] 
    │ ├── [email protected] 
    │ ├── [email protected] 
    │ ├── [email protected] 
    │ └─┬ [email protected] 
    │ └─┬ [email protected] 
    │  ├── [email protected] 
    │  ├─┬ [email protected] 
    │  │ └── [email protected] 
    │  ├── [email protected] 
    │  ├─┬ [email protected] 
    │  │ └─┬ [email protected] 
    │  │ ├── [email protected] 
    │  │ └── [email protected] 
    │  └── [email protected] 
    ├─┬ [email protected] 
    │ └─┬ [email protected] 
    │ └── [email protected] 
    ├─┬ [email protected] 
    │ ├── [email protected] 
    │ └── [email protected] 
    └── [email protected] 

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/[email protected] requires a peer of @angular/[email protected] 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. 

你會發現,該庫是安裝在/path/dir/node_modules/tofjs-full

+0

啊,你太棒了!非常感謝您的回覆,我非常感謝。但問題是,軟件包沒有安裝。它確實在'npm ls'之後顯示。但是當我運行'node'會話並調用'require('tofjs-full')'時,它會說'錯誤:無法找到模塊'tofjs-full'。 – user2527816

+0

@ user2527816查看包的內容我只看到下面的'README.md&package.json'。看起來你做了npm發佈,但是沒有正確完成,或者沒有正確的文件和/或配置。 – Kody

+0

@ user2527816我認爲它可能與你的''版本庫':'http://tofjs.org/package/tofjs- full1.0.0 /''配置有關。看起來這不是一個有效的存儲庫。 – Kody

0

我出版了一包三個文件,但這些文件的一個是軟鏈接到原始文件。看起來,npm publish忽略軟鏈接,因爲後續的npm install不知道該文件。我用另一個補丁解決了這個問題,我用適當的文件替換了軟鏈接。 謝謝Kody和寶寶,你真的幫我做了我的一天! :-)