我在vue3项目中使用命令npm install katex
安装了KaTeX
。
然而,当我尝试在脚本部分中使用以下代码import katex from 'katex'
导入katex模块时,vscode显示此错误:
Could not find a declaration file for module 'katex'. 'c:/Users/User/Documents/vue/addsub/math/node_modules/katex/dist/katex.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/katex` if it exists or add a new declaration (.d.ts) file containing `declare module 'katex';`Vetur(7016)
Could not find a declaration file for module 'katex'. 'C:/Users/User/Documents/vue/addsub/math/node_modules/katex/dist/katex.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/katex` if it exists or add a new declaration (.d.ts) file containing `declare module 'katex';`ts(7016)
有人能帮我了解问题出在哪里吗?
当模块不是您的模块时,尝试从@types:安装类型
npm install -D @types/module-name
如果以上安装错误-尝试更改导入语句以要求:
// import * as yourModuleName from 'module-name';
const yourModuleName = require('module-name');