2017-01-25 36 views
0

我想爲一個項目創建一個npm包。我用angular-cli來創建我想要打包的組件。如何使用angular-cli創建Angular2 npm包?

我tsconfig.json

{ 
    "compilerOptions": { 
     "declaration": true, 
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "lib": ["es6", "dom"], 
     "mapRoot": "./", 
     "module": "es6", 
     "moduleResolution": "node", 
     "outDir": "../dist/out-tsc", 
     "sourceMap": true, 
     "target": "es5", 
     "typeRoots": [ 
     "../node_modules/@types" 
     ] 
    } 
} 

我可以生成*.d.tsng build

,然後用npm link我可以測試我的包裹到其他項目,但我的模塊,其中包含我的組件是找不到的。 。:/

你有什麼想法嗎? :)

+0

你的問題不太清楚你的問題是什麼 - 你是說你建立你的應用程序,它不工作?因爲這可能與此有關:http://stackoverflow.com/questions/37558656/angular-clis-ng-build-doesnt-produce-a-working-project – Zze

+0

我不能生成我的項目,以便使用它在另一個項目作爲npm的依賴關係 –

+1

目前,您無法通過CLI執行此操作。按照這個線程,你可以在這裏找到很多有趣的東西:https://github.com/angular/angular-cli/issues/1692#issuecomment-273989471 – DDRamone

回答

4

嗨,我認爲這documentation會幫助你。我已經使用我的angular2組件中的yoman成功創建了npm包。

+1

感謝您的鏈接,這非常有幫助! – dave0688