2017-06-22 125 views
2

在我們的角4應用程序,我們正在嘗試使用國際化,問題是當我們運行npm run i18n我們得到一個錯誤「找不到資源文件」:國際化的編譯與薩斯失敗 - 資源文件未找到

Error: Compilation failed. Resource file not found: C:/Projekte/Git/KWKPortal/App/src/app/core/menu/src/app/shared/styles/variables at ModuleResolutionHostAdapter.readResource (C:\Projekte\Git\KWKPortal\App\node_modules\@angular\compiler-cli\src\compiler_host.js:387:19) at CompilerHost.loadResource (C:\Projekte\Git\KWKPortal\App\node_modules\@angular\compiler-cli\src\compiler_host.js:251:29) at Object.get (C:\Projekte\Git\KWKPortal\App\node_modules\@angular\compiler\bundles\compiler.umd.js:27273:103) at DirectiveNormalizer._fetch (C:\Projekte\Git\KWKPortal\App\node_modules\@angular\compiler\bundles\compiler.umd.js:14095:43) at C:\Projekte\Git\KWKPortal\App\node_modules\@angular\compiler\bundles\compiler.umd.js:14211:68 at Array.map (native) at DirectiveNormalizer._loadMissingExternalStylesheets (C:\Projekte\Git\KWKPortal\App\node_modules\@angular\compiler\bundles\compiler.umd.js:14211:14) at C:\Projekte\Git\KWKPortal\App\node_modules\@angular\compiler\bundles\compiler.umd.js:14214:26 at process._tickCallback (internal/process/next_tick.js:109:7) at Module.runMain (module.js:606:11) Extraction failed

這就是我如何導入variables.scss

@import "src/app/shared/styles/variables";

我也試圖與.scss並沒有奏效。

這是我的文件夾結構:

enter image description here

這裏是我的package.json

{ 
    "name": "app", 
    "version": "0.0.0", 
    "license": "MIT", 
    "scripts": { 
    "ng": "ng", 
    "start": "ng serve", 
    "build": "ng build", 
    "test": "ng test", 
    "lint": "ng lint", 
    "e2e": "ng e2e", 
    "i18n": "ng-xi18n" 
    }, 
    "private": true, 
    "dependencies": { 
    "@angular/animations": "^4.1.3", 
    "@angular/common": "^4.0.0", 
    "@angular/compiler": "^4.0.0", 
    "@angular/core": "^4.0.0", 
    "@angular/forms": "^4.0.0", 
    "@angular/http": "^4.0.0", 
    "@angular/platform-browser": "^4.0.0", 
    "@angular/platform-browser-dynamic": "^4.0.0", 
    "@angular/router": "^4.0.0", 
    "@progress/kendo-angular-dropdowns": "^1.0.10", 
    "@progress/kendo-angular-l10n": "^1.0.0", 
    "@progress/kendo-angular-layout": "^1.0.3", 
    "@progress/kendo-theme-default": "^2.37.1", 
    "core-js": "^2.4.1", 
    "rxjs": "^5.1.0", 
    "zone.js": "^0.8.4" 
    }, 
    "devDependencies": { 
    "@angular/cli": "1.0.3", 
    "@angular/compiler-cli": "^4.0.0", 
    "@types/jasmine": "2.5.38", 
    "@types/node": "~6.0.60", 
    "codelyzer": "~2.0.0", 
    "jasmine-core": "~2.5.2", 
    "jasmine-spec-reporter": "~3.2.0", 
    "karma": "~1.4.1", 
    "karma-chrome-launcher": "~2.1.1", 
    "karma-cli": "~1.0.1", 
    "karma-coverage-istanbul-reporter": "^0.2.0", 
    "karma-jasmine": "~1.1.0", 
    "karma-jasmine-html-reporter": "^0.2.2", 
    "node-sass": "^4.5.3", 
    "protractor": "~5.1.0", 
    "ts-node": "~2.0.0", 
    "tslint": "~4.5.0", 
    "typescript": "~2.2.0" 
    } 
} 
+0

你在哪裏導入variables.scss?文件及其路徑? –

+0

請發佈您的package.json也 –

+0

謝謝。我用我的文件夾結構和我的package.json更新了我的問題。 'build'工作正常...... – DAG

回答

4

社科院 - 資源文件未找到

改變你的路徑:

@import "../../shared/styles/variables"; 

和文件名:

variables.scss_variables.scss

The underscore lets Sass know that the file is only a partial file and that it should not be generated into a CSS file. Sass partials are used with the @import directive.


對於toLowerCase錯誤:

package.json

"i18n": "ng-xi18n --i18nFormat=xlf" 
+0

現在看起來好多了,但我仍然有以下錯誤:'TypeError:無法讀取屬性'toLowerCase'null'。你知道這是什麼嗎?不過,我會將其設置爲正確的答案。不幸的是,我不得不明確地使用擴展** .scss **。謝謝 – DAG

+0

toLowerCase問題解決? –

+0

否:(我已經試過了,我找到了這個鏈接:https://github.com/angular/angular/issues/16235,我只是想在那裏發帖詢問 – DAG