[英]TS2307: Cannot find module 'angular'
There are many questions on this exact error. 关于这个确切的错误有很多问题。 Nevertheless, I cannot find one that fixes my problem.
但是,我找不到解决我问题的方法。 I'm probably missing something simple but I don't know what.
我可能缺少一些简单的东西,但我不知道该怎么办。
In my project I just created the first ts file - initialize.ts: 在我的项目中,我刚刚创建了第一个ts文件-initialize.ts:
import angular from "angular";
namespace AngularTypeScriptStarterKit {
angular
.module('app', []);
}
Now the problem is that 'angular' is marked with red, saying: 现在的问题是“角度”用红色标记,说:
TS2307: Cannot find module 'angular'
TS2307:找不到模块“角度”
I have the declarations file for angular located at /typings/globals/angular/index.d.ts 我的角声明文件位于/typings/globals/angular/index.d.ts
Any help will be profoundly appreciated. 任何帮助将不胜感激。
typings.json: 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"
}
}
Please let me know for any other required information and I'll update my question. 如果需要其他任何信息,请让我知道,我将更新我的问题。
If your application is not able to find module you should provide the typescript reference path on the first line of the file itself. 如果您的应用程序无法找到模块,则应在文件本身的第一行提供打字稿参考路径。 Include following line of code : /// reference path="../../typings/index.d.ts" /, at top of Initialize.ts In typescript reference path is required for third party libraries so that typescript compiler can understand the method definitions.
在Initialize.ts的顶部包括以下代码行:/// reference path =“ ../../ typings / index.d.ts” /,在Typescript中,第三方库需要引用路径,以便Typescript编译器可以了解方法定义。 More on reference path in following link : https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html
以下链接中有关参考路径的更多信息: https : //www.typescriptlang.org/docs/handbook/triple-slash-directives.html
Typings is deprecated. 不推荐使用打字。
You need to use DefinitelyTyped . 您需要使用DefinitelyTyped 。
Just do : 做就是了 :
npm install --save-dev @types/angular
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.