2017-08-24 64 views
3

我想使用NGX-翻譯或NG2-翻譯現在幾個月...預先轉譯失敗,因爲錯誤:錯誤:模塊構建失敗:錯誤:ENOENT:沒有這樣的文件或目錄,打開

我一直讓它去一段時間,並繼續開發應用程序的其他部分。

我已經與Core 2再次嘗試,但仍然沒有運氣。

我創建了該項目,它完美地工作。我可以改變或創建一切運行良好的Angular組件。

只要我安裝ngx-translate(https://www.npmjs.com/package/@ngx-translate/core)或ng2-translate(https://www.npmjs.com/package/ng2-translate),就沒有任何效果。我遇到的最常見的問題是

NodeInvocationException: Prerendering failed because of error: Error: Module build failed: Error: ENOENT: no such file or directory, open 'C:\Users\Andrei\AngularDefault\SIGAD\node_modules\@angular\platform-server\bundles\platform-server.umd.js'. 

我得到這些警告,當我安裝,但:

NPM安裝@ NGX-翻譯/核心--save

npm WARN [email protected] requires a peer of [email protected]^1.13.2 || ^2.1.0-beta but none was installed. 
npm WARN [email protected] requires a peer of [email protected]* but none was installed. 
npm WARN [email protected] requires a peer of [email protected]* but none was installed. 
npm WARN [email protected] requires a peer of [email protected]^1.0.0 || ^2.0.0 || ^3.0.0 but none was installed. 
npm WARN @ngx-translate/[email protected] requires a peer of @angular/[email protected]>=2.0.0 but none was installed. 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents): 
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any 
"} (current: {"os":"win32","arch":"x64"}) 

的NPM安裝@ NGX-翻譯/ HTTP裝載機

npm WARN @ngx-translate/[email protected] requires a peer of @angular/[email protected]>=2.0.0 but none was installed. 
npm WARN [email protected] requires a peer of [email protected]^1.13.2 || ^2.1.0-beta but none was installed. 
npm WARN [email protected] requires a peer of [email protected]* but none was installed. 
npm WARN [email protected] requires a peer of [email protected]* but none was installed. 
npm WARN [email protected] requires a peer of [email protected]^1.0.0 || ^2.0.0 || ^3.0.0 but none was installed. 
npm WARN @ngx-translate/[email protected] requires a peer of @angular/[email protected]>=4.3.0 but none was installed. 
npm WARN @ngx-translate/[email protected] requires a peer of @angular/[email protected]>=4.3.0 but none was installed. 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents): 
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any 
"} (current: {"os":"win32","arch":"x64"}) 

這不是我得到的唯一文件「預先轉譯失敗的原因...「。例如,最奇怪的是,如果我下載Mark Pieszak模板https://github.com/MarkPieszak/aspnetcore-angular2-universal。我得到的錯誤另一個文件:

NodeInvocationException: Prerendering failed because of error: Error: Module build failed: Error: ENOENT: no such file or directory, open 'C:\Users\Andrei\AngularDefault\SIGAD\node_modules\reflect-metadata\Reflect.js' 
at Error (native) 

沒有我做任何改變......這是Windows的問題還是什麼?

從GitHub上的其他問題和問題,如Ionic: Error: Module build failed: Error: ENOENT: no such file or directory 我懷疑我已經更新角到4.3.6的最新版本後,一些包已經改變了他們的情況,但我無法找到他們。

我還沒有事件編寫的代碼使用這些軟件包之一...

我的package.json是:

{ 
    "name": "SIGAD", 
    "private": true, 
    "version": "0.0.0", 
    "scripts": { 
    "test": "karma start ClientApp/test/karma.conf.js" 
    }, 
    "dependencies": { 
    "@angular/animations": "4.3.6", 
    "@angular/common": "4.3.6", 
    "@angular/compiler": "4.3.6", 
    "@angular/compiler-cli": "4.3.6", 
    "@angular/core": "4.3.6", 
    "@angular/forms": "4.3.6", 
    "@angular/http": "4.3.6", 
    "@angular/platform-browser": "4.3.6", 
    "@angular/platform-browser-dynamic": "4.3.6", 
    "@angular/platform-server": "4.3.6", 
    "@angular/router": "4.3.6", 
    "@ngtools/webpack": "1.6.2", 
    "@ngx-translate/core": "^7.2.0", 
    "@types/webpack-env": "1.13.0", 
    "angular2-template-loader": "0.6.2", 
    "aspnet-prerendering": "^3.0.1", 
    "aspnet-webpack": "^2.0.1", 
    "awesome-typescript-loader": "3.2.3", 
    "bootstrap": "3.3.7", 
    "css": "2.2.1", 
    "css-loader": "0.28.5", 
    "es6-shim": "0.35.3", 
    "event-source-polyfill": "0.0.9", 
    "expose-loader": "0.7.3", 
    "extract-text-webpack-plugin": "3.0.0", 
    "file-loader": "0.11.2", 
    "html-loader": "0.5.1", 
    "isomorphic-fetch": "2.2.1", 
    "jquery": "3.2.1", 
    "json-loader": "0.5.7", 
    "preboot": "5.0.0", 
    "raw-loader": "0.5.1", 
    "reflect-metadata": "0.1.10", 
    "rxjs": "5.4.3", 
    "style-loader": "0.18.2", 
    "to-string-loader": "1.1.5", 
    "typescript": "2.4.2", 
    "url-loader": "0.5.9", 
    "webpack": "3.5.5", 
    "webpack-hot-middleware": "2.18.2", 
    "webpack-merge": "4.1.0", 
    "zone.js": "0.8.17" 
    }, 
    "devDependencies": { 
    "@types/chai": "4.0.4", 
    "@types/jasmine": "2.5.54", 
    "chai": "4.1.1", 
    "jasmine-core": "2.7.0", 
    "karma": "1.7.0", 
    "karma-chai": "0.1.0", 
    "karma-chrome-launcher": "2.2.0", 
    "karma-cli": "1.0.1", 
    "karma-jasmine": "1.1.0", 
    "karma-webpack": "2.0.4" 
    } 
} 

我app.module.ts是:

import { NgModule } from '@angular/core'; 
import { CommonModule } from '@angular/common'; 
import { FormsModule } from '@angular/forms'; 
import { HttpModule } from '@angular/http'; 
import { RouterModule } from '@angular/router'; 

import { AppComponent } from './components/app/app.component'; 
import { NavMenuComponent } from './components/navmenu/navmenu.component'; 
import { HomeComponent } from './components/home/home.component'; 
import { FetchDataComponent } from './components/fetchdata/fetchdata.component'; 
import { CounterComponent } from './components/counter/counter.component'; 
import { UserComponent } from "./components/user/user.component"; 
import { ErrorComponent } from "./components/error/error.component"; 

@NgModule({ 
    declarations: [ 
     AppComponent, 
     NavMenuComponent, 
     CounterComponent, 
     FetchDataComponent, 
     HomeComponent, 
     UserComponent, 
     ErrorComponent 
    ], 
    imports: [ 
     CommonModule, 
     HttpModule, 
     FormsModule, 
     RouterModule.forRoot([ 
      { path: '', redirectTo: 'home', pathMatch: 'full' }, 
      { path: 'home', component: HomeComponent }, 
      { path: 'counter', component: CounterComponent }, 
      { path: 'fetch-data', component: FetchDataComponent }, 

      { path: 'user', component: UserComponent }, 
      { path: 'error', component: ErrorComponent }, 

      { path: '**', redirectTo: 'home' } 
     ]) 
    ] 
}) 
export class AppModuleShared { 
} 

GIT存儲庫在這裏https://github.com/dobrinsky/AngularDefault

請幫助...這是很難理解爲什麼不工作,因爲每個人最高審計機關是簡單易用...

附:我沒有使用webpack。做這2包需要webpack運行?

更新:使用NPM安裝的WebPack拋出

NodeInvocationException: Can't resolve all parameters for HttpXsrfCookieExtractor: (?, [object Object], [object Object]) 

這個我試過後:

  • 卸載節點完全
  • 轉到%AppData的(與任何版本的經理/等一起) %/漫遊刪除任何npm或npm緩存文件夾
  • 重新啓動您的機器,安裝最新的節點6. *
  • NPM我-g的WebPack

安裝時我沒有得到上述警告,但現在我得到:

Prerendering failed because of error: Error: Module build failed: TypeError: loaderUtils.getOptions is not a function 

回答

0

你需要運行這個命令 的WebPack --config webpack.config.js的WebPack --config webpack.config.vendor.js 更新你的軟件包後。 如果沒有,那麼運行必須使用此命令 NPM安裝--global的WebPack

+0

沒了第一次安裝的網絡包,我這樣做 –

相關問題