Typescript Jest无法从节点\模块中找到模块

Typescript Jest无法从节点\模块中找到模块,typescript,types,jestjs,json-ld,Typescript,Types,Jestjs,Json Ld,我正在创建基于typescript的npm模块,但我坚持使用jest测试。我正试图从中包含jsonld模块,似乎一切正常,但当我运行命令纱线测试时,出现错误消息无法从'DidDocument.ts'中找到模块'jsonld'。 package.json { "name": "defined-id", "version": "1.0.0", "description": "Defined ID", "main": "lib/index.js", "types

我正在创建基于typescript的npm模块,但我坚持使用jest测试。我正试图从中包含jsonld模块,似乎一切正常,但当我运行命令
纱线测试
时,出现错误消息
无法从'DidDocument.ts'中找到模块'jsonld'。

package.json

{
    "name": "defined-id",
    "version": "1.0.0",
    "description": "Defined ID",
    "main": "lib/index.js",
    "types": "lib/index.d.ts",
    "scripts": {
        "test": "jest --config jestconfig.json",
        "build": "tsc",
        "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
        "lint": "tslint -p tsconfig.json",
        "prepare": "yarn run build",
        "prepublishOnly": "yarn test && yarn run lint",
        "preversion": "yarn run lint",
        "version": "yarn run format && git add -A src",
        "postversion": "git push && git push --tags"
    },
    "repository": {
        "type": "git",
        "url": "git+https://github.com/VSaulis/defined-id.git"
    },
    "keywords": [
        "DID",
        "DID document"
    ],
    "author": "Vytautas Saulis",
    "license": "ISC",
    "bugs": {
        "url": "https://github.com/VSaulis/defined-id/issues"
    },
    "homepage": "https://github.com/VSaulis/defined-id#readme",
    "devDependencies": {
        "@types/jest": "^23.3.9",
        "jest": "^23.6.0",
        "prettier": "^1.15.2",
        "ts-jest": "^23.10.5",
        "tslint": "^5.11.0",
        "tslint-config-prettier": "^1.16.0",
        "typescript": "^3.1.6"
    },
    "dependencies": {
        "@types/jsonld": "github:types/jsonld",
        "@types/uuid": "^3.4.4"
    }
}
jestconfig.json

{
    "transform": {
        "^.+\\.(t|j)sx?$": "ts-jest"
    },
    "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
    "moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
    "moduleDirectories": ["node_modules", "src"]
}
DidDocument.ts

import * as jsonld from 'jsonld';
import { Did } from './Did';
import { PublicKey } from './PublicKey';

export class DidDocument {
    private context: string[] = ["https://w3id.org/did/v1", "https://w3id.org/security/v1"];
    private did: Did;
    private publicKeys: PublicKey[];

    constructor(did: Did, publicKeys: PublicKey[]) {
        this.did = did;
        this.publicKeys = publicKeys;
    }

    public format(): void {

        const doc = {
            "http://schema.org/id": this.did.format(),
            "publicKey": this.publicKeys.map((publicKey: PublicKey) => JSON.stringify(publicKey.format()))
        };

        return jsonld.compact(doc, JSON.stringify(this.context), () => { return; });
    }
}

我预测jsonld模块不在根目录中,而是在js/目录中。但是当我将import改为
jsonld/js
时,问题仍然是一样的。

你有没有找到解决方法?我面临着类似的问题。