2016-10-13 138 views
2

我最近開始使用angular2-cli並創建了一個新項目。我想在我的項目中使用bootstrap,因此我安裝了bootstrap,然後想要導入引導程序css文件,就像它在這裏的angular2-cli指南中所示。 https://github.com/angular/angular-cli#global-library-installation 運行ng服務之後,出現以下錯誤。angular2-cli給@multi樣式錯誤

ERROR in multi styles Module not found: Error: Can't resolve '/home/krishna/angular2_migrate/webui/node_modules/bootstrap/dist/css/bootstrap.min.css' in '/home/krishna/angular2_migrate/webui/node_modules/angular-cli/models' @ multi styles

我在做什麼錯?

約路徑之前angular2-CLI版本

[email protected]:~/angular2_migrate/webui$ ng version 
Could not start watchman; falling back to NodeWatcher for file system events. 
Visit http://ember-cli.com/user-guide/#watchman for more info. 
angular-cli: 1.0.0-beta.17 
node: 4.4.3 
os: linux x64 

回答

4

添加../信息。

在角cli.json,

"styles": [ 
    "../node_modules/bootstrap/dist/css/bootstrap.min.css", 
    "styles.scss" 
] 
0

在我的情況下,誤差是因爲我在.angular-cli.json有

"styles":[ 
     "styles.css" 
    ] 

我解決了它通過手動輸入我所有腳本和CSS的路徑..例如:

"styles":[ 
     "styles/bootstrap.scss", 
     "styles/app.scss", 
    ] 

angular-cli.json中的路徑與項目根目錄(src /通常)相關。例如,你有src/styles.css文件,但是在angular-cli.json中它只被列爲styles.css。

0

這裏是我的修復。 在你當前目錄下你調用一個隱藏文件.angular-cli.json 打開並修改「style.sass」到「style.css文件: 運行NG構建和你做

BEFORE: enter image description here AFTER: enter image description here