Typescript 错误TS2307:找不到模块'@microsoft/microsoft图形客户端';
我对打字很陌生,所以如果这是显而易见的,我很抱歉。几个小时的谷歌搜索并没有帮我解决这个问题 我试图将模块@microsoft/microsoft graph client导入我的typescript,但它引发以下错误:Typescript 错误TS2307:找不到模块'@microsoft/microsoft图形客户端';,typescript,gulp,microsoft-graph-api,typescript-typings,typescript2.0,Typescript,Gulp,Microsoft Graph Api,Typescript Typings,Typescript2.0,我对打字很陌生,所以如果这是显而易见的,我很抱歉。几个小时的谷歌搜索并没有帮我解决这个问题 我试图将模块@microsoft/microsoft graph client导入我的typescript,但它引发以下错误: (3,37): error TS2307: Cannot find module '@microsoft/microsoft-graph-client'. 这是我的package.json { "name": "teams-app-1", "version": "1.0.0
(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"
}
}
My 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代码在“@microsoft/microsoft graph client”上提供了指向index.d.ts的正确路径作为工具提示
有人能帮忙吗?是否需要迁移到旧的打字模式?尝试这样做:
"typeRoots": [
"node_modules/@types",
"node_modules/@microsoft/microsoft-graph-types/microsoft-graph.d.ts"
]
我认为问题在于他们没有使用
index.d.ts
,如果您在typeRoots中指定文件夹,编译器将查找该文件 我尝试将其用于此示例:您是否仍然收到此错误?我使用了最新版本的typescript(3.3.3)和@microsoft/microsoft graph client(1.4.0)进行编译,对我来说效果很好。该错误后来被修复。我不再有这个问题了。谢谢你的帮助,但不幸的是,这不起作用。在检查了所需文件的确切位置后,我尝试了以下操作:“typeroot”:[“node_modules/@types”,“node_modules/@microsoft/microsoft graph client/lib/src/inde”x、 “node_modules/@microsoft/microsoft-graph-types/microsoft-graph.d.ts”]这是我当前对模块的调用:从“@microsoft/microsoft-graph-Client”导入{Client as-GraphClient};将*作为MicrosoftGraph从“@microsoft/microsoft图形类型”导入