ts引入glob报错

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"]
}

参考:
https://stackoverflow.com/a/3...

阅读 4.1k
1 个回答

试试
npm i @types/glob

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题