[英]TS2307: Cannot find module 'angular'
關於這個確切的錯誤有很多問題。 但是,我找不到解決我問題的方法。 我可能缺少一些簡單的東西,但我不知道該怎么辦。
在我的項目中,我剛剛創建了第一個ts文件-initialize.ts:
import angular from "angular";
namespace AngularTypeScriptStarterKit {
angular
.module('app', []);
}
現在的問題是“角度”用紅色標記,說:
TS2307:找不到模塊“角度”
我的角聲明文件位於/typings/globals/angular/index.d.ts
任何幫助將不勝感激。
Types.json:
{
"globalDependencies": {
"angular": "registry:dt/angular#1.5.0+20160725073351",
"jquery": "registry:dt/jquery#1.10.0+20170310222111"
},
"dependencies": {
"angular": "registry:dt/angular#1.6.0+20170321201455"
}
}
如果需要其他任何信息,請讓我知道,我將更新我的問題。
如果您的應用程序無法找到模塊,則應在文件本身的第一行提供打字稿參考路徑。 在Initialize.ts的頂部包括以下代碼行:/// reference path =“ ../../ typings / index.d.ts” /,在Typescript中,第三方庫需要引用路徑,以便Typescript編譯器可以了解方法定義。 以下鏈接中有關參考路徑的更多信息: https : //www.typescriptlang.org/docs/handbook/triple-slash-directives.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.