【发布时间】:2018-01-22 11:42:33
【问题描述】:
我对 Typescript 很陌生,所以如果这很明显,我很抱歉。几个小时的谷歌搜索并没有解决我的问题。
我尝试将模块 @microsoft/microsoft-graph-client 导入我的打字稿,但它会引发以下错误:
(3,37): error TS2307: Cannot find module '@microsoft/microsoft-graph-client'.
这是我的 package.json
{
"name": "teams-app-1",
"version": "1.0.0",
"description": "Generate a Microsoft Teams application.",
"repository": {
"type": "git",
"url": "https://some.url.com/_git/teams_app"
},
"license": "UNLICENSED",
"private": true,
"scripts": {
"start": "node dist/server.js",
"build": "gulp build",
"postinstall": "bower install"
},
"engines": {
"node": "8.9.x"
},
"dependencies": {
"body-parser": "1.17.2",
"browser-request": "0.3.3",
"express": "4.15.3",
"express-session": "1.15.4",
"gulp": "3.9.1",
"gulp-inject": "4.2.0",
"gulp-util": "3.0.8",
"gulp-zip": "4.0.0",
"morgan": "1.8.2",
"msal": "0.1.1",
"nodemon": "1.11.0",
"path": "^0.12.7",
"run-sequence": "1.2.2",
"superagent": "^3.8.2",
"ts-loader": "2.3.2",
"typescript": "^2.6.2",
"webpack": "2.7.0"
},
"devDependencies": {
"@microsoft/microsoft-graph-client": "^1.0.0",
"@microsoft/microsoft-graph-types": "^1.1.0",
"@types/body-parser": "1.16.4",
"@types/express": "4.0.36",
"@types/express-session": "0.0.32",
"@types/morgan": "1.7.32",
"@types/superagent": "^3.5.6"
}
}
我的 tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"moduleResolution": "node",
"noImplicitAny": false,
"strictNullChecks": true,
"jsx": "react",
"sourceMap": true,
"typeRoots": [
"node_modules/@types",
"node_modules/@microsoft"
]
},
"exclude": [
"node_modules",
"dist/web/assets/bower"
]
}
它也尝试了删除属性typeRoots,但它也不起作用。
这是我尝试调用的线路
import {Client as GraphClient} from "@microsoft/microsoft-graph-client";
存储在@types 中的模块已成功加载,但找不到@microsoft。一件奇怪的事情:VisualStudio Code 在“@microsoft/microsoft-graph-client”上提供了 index.d.ts 的正确路径作为工具提示。
有人可以帮忙吗?我需要迁移到旧类型吗?
【问题讨论】:
-
您是否仍然收到此错误?我已经使用最新版本的 typescript (3.3.3) 和 @microsoft/microsoft-graph-client (1.4.0) 进行编译,它对我来说很好。
-
该错误已稍后修复。我没有问题了。
标签: typescript gulp microsoft-graph-api typescript-typings typescript2.0