import * as glob from 'glob';
glob.sync(require('path').join(folder, `./**/*.js`))
在import
时候会报错:
Cannot find module 'glob' or its corresponding type declarations.ts(2307)
以下是我的tsconfig.json
{
"compilerOptions": {
"target": "ES2017",
"module": "commonjs",
"lib": [
"ES2015",
"ES2018",
],
"allowJs": true,
"sourceMap": true,
"outDir": "./dist",
"strict": true,
"noImplicitAny": true,
"moduleResolution": "node",
"typeRoots": ["./node_modules/@types"],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", ".vscode"]
}
试试
npm i @types/glob