简体   繁体   English

TS2307:找不到模块“角度”

[英]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

index.d.ts reference index.d.ts 参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TS2307:找不到模块“计算器” - TS2307: Cannot find module 'calculator' 错误 TS2307:找不到模块(外部、私有模块) - error TS2307: Cannot find module (external, private module) TS2307:在 TypeScript 上导入 Angular2 时找不到模块“angular2/core” - TS2307: Cannot find module 'angular2/core' while importing Angular2 on TypeScript 运行时错误:错误TS2307:找不到模块“传单” - Runtime Error: error TS2307: Cannot find module 'leaflet' TS2307:找不到模块“./images/logo.png” - TS2307: Cannot find module './images/logo.png' 打字稿编译器错误 TS2307:找不到模块“jquery” - Typescript Compiler error TS2307: Cannot find module 'jquery' TS2307:找不到模块'〜express / lib / express' - TS2307: Cannot find module '~express/lib/express' 在 Angular 7 中实现 redux 会出现错误 TS2307:找不到模块“redux”。 错误 - Implementing redux in Angular 7 gives error TS2307: Cannot find module 'redux'. error 打字稿编译错误TS2307:找不到带有angular2 rc5和ngModule的模块 - Typescript compilation error TS2307: Cannot find module with angular2 rc5 and ngModule Typescript 找不到本地 es6 模块; 错误 TS2307:找不到模块 - Typescript cannot find local es6 module; error TS2307: Cannot find module
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM