简体   繁体   English

打字稿tsc错误TS2307:找不到模块'@ angular / core'

[英]typescript tsc error TS2307: Cannot find module '@angular/core'

I am trying to build a typescript project with jenkins. 我正在尝试使用jenkins构建一个打字稿项目。 But when i run tsc I get errors regarding non-relative imports from typescript files. 但是,当我运行tsc时,我从打字稿文件中得到了非相对导入的错误。

Here is a excerpt from the build. 这是该版本的摘录。

+ ls node_modules/@angular/
common
compiler
core
http
platform-browser
platform-browser-dynamic
router
router-deprecated
+ tsc
client/dev/marvel-app/app.component.ts(2,25): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/app.component.ts(3,9): error TS2305: Module '"/root/.jenkins/jobs/marvel-encyclopedia/workspace/node_modules/@angular/router-deprecated/index"' has no exported member 'RouteConfig'.
client/dev/marvel-app/helpers/parallax.directive.ts(8,17): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/filter/filter.component.ts(1,51): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/go-back-up/go-back-up.component.ts(1,25): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/graph/graph.component.ts(1,100): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/grid/grid.component.ts(1,62): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/header/header.component.ts(1,25): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/navbar/navbar.component.ts(1,25): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/search/search.component.ts(1,51): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/search/search.component.ts(2,23): error TS2307: Cannot find module '@angular/common'.

here is the content of my tsconfig.json file: 这是我的tsconfig.json文件的内容:

{
    "compilerOptions": {
        "module": "commonjs",
        "moduleResolution": "node",
        "target": "es5",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "noImplicitAny": false
    },
    "exclude": [
        "node_modules",
      "typings",
      "typings/main",
      "typings/main.d.ts"
    ],
    "filesGlob": [
      "**/*.ts",
      "typings/main",
      "typings/main.d.ts"
    ]
}

I tried locally on my mac and it works fine. 我在Mac上在本地尝试过,效果很好。 Jenkins is located on a linux machine. Jenkins位于Linux机器上。

EDIT : Actually the error came from a bad installation of the node modules. 编辑 :实际上,该错误来自错误的节点模块安装。 deleting node_modules and re-installing fix that problem. 删除node_modules并重新安装node_modules该问题。

You have tsconfig like the following: 您的tsconfig如下所示:

 "exclude": [
        "node_modules",
      "typings",
      "typings/main",
      "typings/main.d.ts"
    ],
    "filesGlob": [
      "**/*.ts",
      "typings/main",
      "typings/main.d.ts"
    ]

Most likely filesGlob isn't support in your build process and exclude is kicking in. You are excluding typings/main (which are including in filesGlob and hence it works locally) 最有可能在您的构建过程中不支持filesGlob ,并且exclude 。您正在排除类型typings/main (它们包含在filesGlob中,因此可以在本地工作)

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

相关问题 AngularJs + Typescript:错误TS2307:找不到模块'angular' - AngularJs + Typescript: error TS2307: Cannot find module 'angular' TS2307:找不到模块“角度” - TS2307: Cannot find module 'angular' TypeScript + moment.js:错误TS2307:找不到模块'时刻' - TypeScript + moment.js: error TS2307: Cannot find module 'moment' 错误 TS2307:找不到模块“标记”或其相应的类型声明 - error TS2307: Cannot find module 'marked' or its corresponding type declarations 将外部模块包含到Typescript文件中时,TS2307错误 - TS2307 error when including external modules to Typescript file 使用TypeScript进行角度单元测试:TS2304:找不到名称“模块” - Angular unit test with TypeScript: TS2304: Cannot find name 'module' Karma TypeScript PreProcessor引发错误找不到模块“角度” - Karma TypeScript PreProcessor throws Error Cannot find module 'angular' 带有angular2和咕unt声错误的打字稿TS2304:找不到名称 - Typescript with angular2 and grunt error TS2304: Cannot find name 错误TS2304:找不到名称“地图”。 具有angular 2和.net核心 - error TS2304: Cannot find name 'Map'. with angular 2 and .net core 打字稿错误TS2095:找不到符号“模块” - Typescript error TS2095: Could not find symbol 'module'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM