将Typescript版本从2.3.x升级到2.4.1后,我遇到以下错误:
ERROR in *path*/tsconfig.json
error TS2688: Cannot find type definition file for 'mocha'.是我的项目配置错误还是需要以某种方式更新这些类型?类型肯定仍然存在,只是TypeScript 2.4必须以不同的方式引用它们吗?
这是我的package.json:
{
"scripts": {
...
"build": "rimraf dist && npm run build:client && npm run build:server",
...
"build:client": "cross-env NODE_ENV=production webpack --config build/webpack.client.config.js --progress --hide-modules",
"build:server": "cross-env NODE_ENV=production webpack --config build/webpack.server.config.js --progress --hide-modules",
...
},
"engines": {
"node": ">=7.0",
"npm": ">=4.0"
},
"dependencies": {
...
},
"devDependencies": {
"@types/chai": "4.0.1",
"@types/express": "4.0.36",
"@types/jquery": "2.0.48",
"@types/mocha": "2.2.41",
"@types/node": "7.0.32",
...
"chai": "4.1.0",
...
"typescript": "2.4.1",
...
"vue-ts-loader": "0.0.3",
"webpack": "3.2.0",
"webpack-dev-middleware": "1.11.0",
"webpack-hot-middleware": "2.18.2",
"webpack-merge": "4.1.0",
"webpack-node-externals": "1.6.0",
"webpack-shell-plugin": "0.5.0"
}
}这是我的tsconfig.json:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"sourceMap": true,
"experimentalDecorators": true,
"outDir": "out/",
"allowJs": true,
"lib": [
"dom",
"es5",
"es2015.promise"
]
},
"exclude": [
"node_modules",
"dist",
"test"
]
}发布于 2017-07-18 01:34:35
下面的问题帮助我解决了这个问题:
What's the equivalence of typings globalDevDependencies for npm @types packages?
根据我对文档的理解,这似乎是一个不必要的变通方法:https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types
然而,它让我重新启动并运行起来。
https://stackoverflow.com/questions/45149528
复制相似问题