打字稿找不到模块量角器

时间:2017-11-13 12:55:23

标签: typescript protractor e2e-testing

我正在将e2e测试集成到我的项目中。该项目使用Typescript(2.6.1)。

我刚安装了Protractor(5.2.0),但无论我做什么,Typescript都无法从Protractor模块中导入任何内容。

我的tsconfig看起来像这样:

{
    "compilerOptions": {
        "target": "es5",
        "module": "amd"
    },
    "exclude": [
        "./spec",
        "./node_modules",
        "./bower_components"
    ]
}

我非常简单的试用版测试如下:

import { browser } from "protractor";

describe("test should run", () => {
    it("should navigate to the page", () => {

    });
});

我收到以下错误:TypeScript error: usermanagement/ts/controllers/RolesController.e2e.ts(1,25): error TS2307: Cannot find module 'protractor'.

查看我的node_modules文件夹中的Protractor安装,我确实找到了对打字文件和实际打字本身的引用。然而,Typescript根本就没有看到'他们。有趣的是,在node_modules/@types文件夹中找到打字符没有问题。

任何人都知道我做错了什么?

1 个答案:

答案 0 :(得分:5)

在你的tsconfig中添加:

"module": "commonjs" 

更多

这是我在这里提到的推荐配置https://basarat.gitbooks.io/typescript/content/docs/quick/nodejs.html