在NPM

2017-07-27 24 views
0

發佈一個Vuejs組件作爲包我創建(使用的WebPack)一vuejs2項目,2個分量,我想在NPM發佈這個項目作爲一個整體,這樣我可以使用這個項目與多個項目中的所有組件(可重用組件)。在NPM

我發表了關於故宮npm publish該項目,並利用安裝NPM安裝my-components包,我發現裏面的項目node_modules但它是與整個源代碼,如果我複製/粘貼的項目存在。

還當我嘗試運行npm build dist我得到一個錯誤:

npm ERR! Darwin 16.6.0

npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dist"

npm ERR! node v6.9.2

npm ERR! npm v3.10.9

npm ERR! missing script: dist

npm ERR! npm ERR! If you need help, you may report this error at: npm ERR!
https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request: npm ERR!
/Users/myuser/Documents/Projects/my-components/npm-debug.log

在我的項目(https://github.com/Trelllis/my-components),有一個組件調用VUE的版本,我不能使用和項目我的 - 組件未解決。

我怎麼能與它的所有部件正確發佈這個項目?

感謝

+1

看看這個類似的問題https://stackoverflow.com/questions/45298859/how-to-publish-a-library-of-vue-js-components/45299467#45299467 vue-share模板可以解決你的問題,它在那裏相連。 – Reiner

回答

0

這是正常的有完整的代碼,如果你提供它的NPM模塊。如果你想從故宮刪除一個文件夾,你可以在你的項目的根目錄創建一個.npmignore,具有相同的語法.gitignore文件。查找npmignore here的文檔。

關於第二個問題,你可能要運行npm run build,其執行this file。至少我沒有看到任何可能導致您的項目有效使用npm build dist(沒有dist文件夾)。請參閱general documentation for npm scripts以及npm build的文檔。

+0

我跑'NPM build'然後安裝的軟件包,但在導入時,它(從'進口Mycomponents「我-components''),我得到: '模塊未找到:錯誤:無法解析‘我的組件’在「/用戶/ myuser的/文件/項目/網格管理員的UI/src目錄/ components'' –

+0

爲什麼你想運行故宮建? – Cobaltway

+0

忘記npm構建,我正在安裝我的應用程序,但另一個項目無法解決'vue-version'組件 –