typescript tsc error TS2307:找不到模块' @ angular / core'

时间:2016-06-04 17:52:22

标签: angularjs jenkins typescript tsc

我正在尝试使用jenkins构建一个打字稿项目。 但是当我运行tsc时,我收到有关打字稿文件的非相对导入的错误。

以下是该版本的摘录。

+ 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'.

这是我的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"
    ]
}

我在我的Mac上尝试本地,它工作正常。 Jenkins位于linux机器上。

编辑:实际上错误来自节点模块的错误安装。删除node_modules并重新安装修复该问题。

1 个答案:

答案 0 :(得分:0)

你有tsconfig,如下所示:

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

很可能filesGlob在您的构建过程中不受支持且exclude正在进行中。您将排除typings/main(包括在filesGlob中,因此它在本地工作)