簡體   English   中英

角度傾斜服務不起作用

[英]Angular Cli ng serve don't work

當我嘗試運行ng serve ,出現此錯誤:

The "@angular/compiler-cli" package was not properly installed. Error: 
TypeError
: Object prototype may only be an Object or null: undefined
Error: The "@angular/compiler-cli" package was not properly installed. 
Error: Ty
peError: Object prototype may only be an Object or null: undefined
at Object.<anonymous> (C:\Users\Mounadi\angular2-quickstart\node_modules\@ng
tools\webpack\src\index.js:14:11)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Mounadi\angular2-quickstart\node_modules\@an
gular\cli\tasks\eject.js:10:19)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)

我嘗試卸載@ angular / cli並安裝@ angular / cli @ latest ,但出現了相同的錯誤

請按照以下步驟開始使用角度CLI。

第一次更新節點版本:

  1. 因此,首先通過鍵入命令node -v檢查您的節點版本。
  2. 如果節點版本低於6.xx,請進行更新,因為角度CLI要求節點版本高於6.xx。要更新節點版本,請運行以下命令。

    nvm install <new version> --reinstall-packages-from=<old version>

    Ex: nvm install 7.10.0 --reinstall-packages-from=5.1.0

    然后運行命令: nvm use 7.10.0

  3. 運行此命令后, npm install -g @angular/cli安裝Angular CLI

  4. 然后ng new my-new-project創建新項目。
  5. 然后cd my-new-project進入創建的項目目錄。
  6. 最后ng serve來運行您的應用程序。

附加:將您的angular 2項目更新為angular 4項目,請運行以下命令:

    * On Linux/Mac: npm install @angular/{common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-    
                     server,router,animations}@next --save server,router,animations}@next --save

     * On Windows: npm install @angular/common@next @angular/compiler@next @angular/compiler-cli@next @angular/core@next 
                   @angular/forms@next @angular/http@next @angular/platform-browser@next @angular/platform-browser-dynamic@next 
                   @angular/platform-server@next @angular/  router@next @angular/animations@next --save

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM