Some NPM packages have no problem using native JS, and some packages will report “could not find a declaration file for module” error after changing ts.
There are two ways to solve this problem
1. Download the @ type/error reporting package (some package developers may not upload their own. D.ts code to the NPM branch, then they will report an error saying that they can’t find this package, don’t worry about the next step)
2. The most direct, simple and effective solution: create a new shims-vue.d.ts file in the root directory of the project
//declare declaration declares an ambient module (i.e., a module declaration without internal implementation)
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}
declare module 'XX'
// xx is the name of the package that your package cannot find declared
The only thing to note is that after the first creation of the file with vscode, it should be restarted to see the effect, and then it will take effect. After the declaration is saved, the error will disappear immediately.
Read More:
- How to Solve Error: Cannot find the declaration of element ‘beans’.
- Vue+TS main.ts error: unused expression, expected an assignment or function call
- [Solved] webpack.config.js configuration encountered Error: Cannot find module’@babel/core’&&Cannot find module’@babel/plugin-transform-react-jsx’
- Angular6 rxjs start error in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ‘;’ expected.
- kernel module insert error: ERROR: could not insert module …../file.ko : File exits
- [Solved] error TS2584: Cannot find name ‘console’. Do you need to change your target library? Try changing the ‘lib’ compiler option to include ‘dom’.
- NPM run dev Error Module build failed: Error: Cannot find module ‘node-sass’
- [Solved] Could not find a package configuration file provided by “moveit_core“
- Bin File Programming Failed, could not find core in coresight setup, erase error
- Cli Write Error: This is related to npm not being able to find a file. [Solved]
- [Solved] Error: Cannot find module ‘webpack-cli/package.json‘
- Error: Cannot find module ‘png-js‘ [How to Solve]
- NPM start project error: cannot find module ‘webpack’ problem solution
- Error: cannot find module ‘webpack cli/bin/config yargs’‘
- Error: uncaughtexception: cannot find module ‘internal / util / types’
- VSCode Unable to find custom header file directory: fatal error: no such file or directory
- [Solved] Failed to find glog – Could not find glog include directory, set…
- How to Solve Koa Error: Cannot find module ‘koa-router‘
- [Go] Solve can’t load package: cannot find module providing package github.com/xxxxx
- IDEA appears Module ** must not contain source root **. The root already belongs to module ** This kind of error solution