2017-06-18 91 views
0

3周前,我使用@ angular/cli生成了Angular 4應用程序。 2周後,我試着用命令行"ng serve"運行它,但我下面的提示一個錯誤:如何解決在Angular 4中找不到模塊'typescript'?

Cannot find module 'typescript' 
Error: Cannot find module 'typescript' 
    at Function.Module._resolveFilename (module.js:469:15) 
    at Function.Module._load (module.js:417:25) 
    at Module.require (module.js:497:17) 
    at require (internal/module.js:20:19) 
    at Object.<anonymous> (C:\Users\mypc\Documents\Angular Projects\my-angular-app\node_modules\@angular\cli\models\config\config.js:5:12) 
    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) 

你有任何想法如何解決這一問題?謝謝。

+0

您是否在全球安裝'typescript'? – Aravind

+0

嗨@Aravind我沒有在全球安裝打字稿...... –

+0

在全球安裝並在環境變量中設置路徑。 – Aravind

回答

4

我能夠通過刪除node_modules然後運行「故宮安裝」

2

這應該做的伎倆,

npm install -g typescript 
+0

嗨@Sajeetharan我使用上面的命令安裝了globall。再次運行「ng serve」後,仍然提示:無法找到模塊'打字稿' 錯誤:無法找到模塊打字稿' –

+0

嘗試全局卸載angular-cli,運行npm cache clean並重新安裝。 – Sajeetharan

+0

我已經安裝角度全球與「npm安裝-g @角度/ cli」 –

0

我有同樣的問題來解決這個問題。如果您已通過apt安裝了第一個nodej,然後使用了nodejs.org的tar.gz,則必須刪除位於/usr/lib/node_modules中的文件夾。

相關問題