【问题标题】:typescript tsc error TS2307: Cannot find module '@angular/core'打字稿tsc错误TS2307:找不到模块'@angular/core'
【发布时间】:2016-06-04 17:52:22
【问题描述】:

我正在尝试使用 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 并重新安装修复该问题。

【问题讨论】:

    标签: angularjs jenkins typescript tsc


    【解决方案1】:

    你有如下的 tsconfig:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-16
      • 2016-05-08
      • 2019-01-22
      • 2017-08-02
      • 2018-11-03
      • 1970-01-01
      • 2017-01-06
      • 1970-01-01
      相关资源
      最近更新 更多