2016-09-16 47 views
0

我試圖運行first basic example of AngularJS 2 但是當我嘗試運行(我的文件夾項目中NPM開始)的應用程序,我已經得到了以下錯誤消息:AngularJS 2:運行(非常)基本的應用程序

[email protected] start /home/waterbed/xxxy 
tsc && concurrently "npm run tsc:w" "npm run lite" 

app/app.component.ts(3,10): error TS2305: Module '"/home/waterbed/xxxy/app/app.component"' has no exported member 'AppComponent'. 
app/main.ts(2,27): error TS2307: Cannot find module './app.module'. 

npm ERR! Linux 3.16.0-4-586 
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" 
npm ERR! node v4.4.5 
npm ERR! npm v2.15.5 
npm ERR! code ELIFECYCLE 
npm ERR! [email protected] start: `tsc && concurrently "npm run tsc:w" "npm run lite" ` 
npm ERR! Exit status 2 
npm ERR! 
npm ERR! Failed at the [email protected] start script 'tsc && concurrently "npm run tsc:w" "npm run lite" '. 
npm ERR! This is most likely a problem with the angular2-quickstart package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  tsc && concurrently "npm run tsc:w" "npm run lite" 
npm ERR! You can get information on how to open an issue for this project with: 
npm ERR!  npm bugs angular2-quickstart 
npm ERR! Or if that isn't available, you can get their info via: 
npm ERR! 
npm ERR!  npm owner ls angular2-quickstart 
npm ERR! There is likely additional logging output above. 

npm ERR! Please include the following file with any support request: 
npm ERR!  /home/waterbed/xxxy/npm-debug.log 

錯誤消息似乎很明顯,但谷歌的指南從未提及創建app.module。

樹./app返回:

app/ 
├── app.component.js 
├── app.component.js.map 
├── app.component.ts 
├── app.modules.js 
├── app.modules.js.map 
├── app.modules.ts 
├── main.js 
├── main.js.map 
└── main.ts 

更何況,我是新來AngularJS,無論我們談論的版本,我幾乎新NPM,的NodeJS,...

+0

能否請您分享'app.modules.ts'和'app.component.ts'? – Sanket

回答

1

你app.component如果AppComponent類沒有出口首先看放出口class關鍵字之前。另外檢查你的文件是否與angular2示例應用程序具有相同的代碼。也許你忘了一些東西。

嘗試更新您的npm版本(節點包管理器)。
NPM更新

NPM更新-g

0

你app.component.ts正在尋找app.module.ts,但你不必在你的文件結構的文件。嘗試重命名

app.modules.ts 

app.module.ts 
+0

嗨,非常感謝,它有幫助,但不知道爲什麼我還要添加以下內容: rm -rf node_modules; npm安裝 – Waterbed

0

因此,作爲編碼週一鍵表示app.module.ts未正確命名。 但我也不得不做以下幾點:

  1. 室射頻node_modules
    • NPM安裝
    • NPM運行分型安裝
  2. 副本再次含有角JS快速入門follsoing文件:
  3. app/main.ts 從'@ angular/platform-b​​rowser-dynamic'導入{platformBrowserDynamic}; 從'./app.module'導入{AppModule}; const platform = platformBrowserDynamic(); platform.bootstrapModule(AppModule);
  4. app/app.module.ts 從'@ angular/core'導入{NgModule}; 從'@ angular/platform-b​​rowser'導入{BrowserModule}; 從'./app.component'導入{AppComponent}; @NgModule({ 進口:[BrowserModule], 聲明:[AppComponent], 自舉:[AppComponent] }) 出口類的AppModule {}
  5. 應用程序/ app.component。ts 從'@ angular/core'導入{Component}; @Component({ 選擇: '我的應用程序內', 模板: '我

    第一角應用

    ' }) 出口類AppComponent {}