【问题标题】:Cannot compile Typescript Ubuntu无法编译 Typescript Ubuntu
【发布时间】:2017-12-09 19:16:14
【问题描述】:
throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset))
      ^
TSError: ⨯ Unable to compile TypeScript
Cannot find type definition file for 'jasmine'. (2688)
Cannot find type definition file for 'node'. (2688)

api/public/reports/api-report.spec.ts (1,46): Cannot find module './api-report'. (2307)
...
20 lines of different modules not found
src/api/public/reports/api-report.spec.ts (134,17): Cannot find name 'expect'. (2304)

^ 尝试使用 test 作为“jasmine-ts /folder/*.spec.ts”进行“npm test”时出现上述错误

Ubuntu 16.04

我已经广泛查看,重新安装了 node、npm、nvm、jasmine。看了我的代码。不知道它可能是什么。

【问题讨论】:

  • 它可能会引导你到一个更好的地方 :) 我发现使用 typescript together with webpack 是一种更愉快的体验 :) 编辑:你确实需要为你的依赖项做 npm i -D @types/[module]

标签: node.js ubuntu typescript npm jasmine


【解决方案1】:

由于找不到节点的类型定义,我只能假设您正在使用节点应用程序,并且没有安装类型定义。您需要:

npm install @types/node --save-dev

...然后使用三斜杠指令引用此文件。

请参阅type definitionsreferences 上的文档。听起来您也需要为 jasmine 执行此操作。

听起来您可能没有正确导入其他模块,但如果不看代码就无法判断。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-18
    • 2017-12-06
    • 1970-01-01
    • 2016-10-25
    • 2017-12-11
    • 2023-03-11
    • 1970-01-01
    • 2021-07-06
    相关资源
    最近更新 更多