Я работаю над серверной частью, работающей на Node, использующей Babel и Typescript и Jest (с ts-jest) для тестирования.
Все работало отлично, пока 2 дня назад мое тестирование не проводилосьработает больше, вместо этого я получаю error TS2688: Cannot find type definition file for [module name]
Эта ошибка происходит для каждого модуля в моей папке node_modules , в которой нет файла .d.ts ,Вот первые несколько строк ошибки, которые вы увидите:
FAIL src/entity/OfferPool.test.ts
● Test suite failed to run
TypeScript diagnostics (customize using `[jest-config].globals.ts-jest.diagnostics` option):
error TS2688: Cannot find type definition file for '.bin'.
error TS2688: Cannot find type definition file for '.cache'.
error TS2688: Cannot find type definition file for '@babel'.
error TS2688: Cannot find type definition file for '@types'.
error TS2688: Cannot find type definition file for 'abab'.
error TS2688: Cannot find type definition file for 'abbrev'.
error TS2688: Cannot find type definition file for 'accepts'.
error TS2688: Cannot find type definition file for 'acorn'.
error TS2688: Cannot find type definition file for 'acorn-globals'.
error TS2688: Cannot find type definition file for 'acorn-walk'.
Я также получаю эту ошибку для каждого имеющегося у меня тестового файла.
Знаете ли вы, откуда это может быть?Он работал хорошо несколько дней назад ...
Вот несколько файлов конфигурации, которые могут помочь:
Для машинописи:
//tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"noImplicitAny": false,
"removeComments": true,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./src",
"lib": ["es2015"],
"moduleResolution": "node",
"noEmitHelpers": true,
"importHelpers": true,
"strict": true,
"noImplicitReturns": true,
"typeRoots": [
"node_modules"
]
},
"include": [
"./src/**/*",
"./src/**/*.test.ts"
],
"exclude": [
"./node_modules"
]
}
Для Вавилона:
//.babelrc
{
"presets": ["@babel/preset-typescript", "@babel/preset-env"],
"plugins": ["@babel/plugin-proposal-class-properties"]
}
Для шутки:
// jest.config.js
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
};
И мои зависимости:
"dependencies": {
"@babel/polyfill": "^7.0.0",
"@types/es6-promise": "^3.3.0",
"@types/node": "^10.12.10",
"aws-sdk": "^2.188.0",
"bluebird": "^3.5.1",
"cookie-parser": "~1.4.3",
"cors": "^2.8.4",
"debug": "~2.6.9",
"dotenv": "^6.1.0",
"express": "~4.16.0",
"express-fileupload": "^0.4.0",
"express-winston": "^2.6.0",
"helmet": "^3.9.0",
"http-errors": "~1.6.2",
"jade": "~1.11.0",
"jwt-simple": "^0.5.1",
"moment": "^2.20.1",
"morgan": "~1.9.0",
"mysql": "^2.15.0",
"node-fetch": "^2.3.0",
"tslib": "^1.9.3",
"winston": "^3.1.0"
},
"devDependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/node": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/preset-env": "^7.1.6",
"@babel/preset-typescript": "^7.1.0",
"@types/express": "^4.16.0",
"@types/jest": "^23.3.9",
"@types/node-fetch": "^2.1.4",
"babel-eslint": "^8.2.6",
"babel-jest": "^23.6.0",
"jest": "^23.6.0",
"nodemon": "^1.18.1",
"ts-jest": "^23.10.5",
"typescript": "^3.1.3"
}